How to compare colors in array and pixel on image and produce new image with closest color in the array iOS?

For people new to Quartz 2D/Core graphic. Here is the link that helped me a lot to understand more about Quart 2D and guided me right direction to solve my problem.

Up vote 0 down vote favorite share g+ share fb share tw.

Im trying to process an input image by reading all data pixel of it then compare with all colors that I have in an Array to produce new image. But I got lost into problems and stuck. Please help, this is what I have now.

//This is find different of two UIColor int ColorDiff(UIColor *color1 ,UIColor *color2){ ...Compare RGB components going on } My first try // init vars int d = 0; // squared error int idx = 0; // index of color int min = 1000000; // min difference int paletteSize = pathArray. Count; // number of available color UIColor *currentRGB; // current color at a pixel in image UIColor *paletteRGB; // palette color // visit each output pixel and determine closest color from array for(int y=0; y CGImage; //inputImgAvg is image at begin CFDataRef theData; theData = CGDataProviderCopyData(CGImageGetDataProvider(srcImgProcess)); UInt8 *pixelData = (UInt8 *) CFDataGetBytePtr(theData); int dataLength = CFDataGetLength(theData); //PROBLEM IS HERE... //Now I loop thru the pixeldata for (int I = 0; I // That's all my thought right now. // If you guys have any idea, please help to solve this.

} Please help me. Any advices would be greatly appreciated ios image-processing core-graphics link|improve this question edited Jan 26 at 20:40 asked Jan 26 at 20:34JHHoang848 71% accept rate.

If so, it is an array holding colors(only 1px of that colors) that I obtained from different part of the code. – JHHoang Jan 26 at 22:11 These colors are not from original image. For example, if the array holding only black and white color then the output image should be black&white only.

– JHHoang Jan 26 at 22:18.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions