Page 1 of 1

Read each pixel and neighbours with Image.pixelColor()

Posted: 2008-06-12T03:08:53-07:00
by LiloLilo
Hi,

I need to access each pixel of an image one by one, from left to right, top to bottom. For each pixel, I need to read the pixel itself, the left neighbour and the top one, do some calculations, store the result on another image, and then go on with the next. Is there any solution better than read each pixel one by one with Image.pixelColor()? May a pixel cache improve performances? I am using Magick++ with Visual C++ 8.0

thank you for help.

Re: Read each pixel and neighbours with Image.pixelColor()

Posted: 2008-06-12T17:17:05-07:00
by anthony
For best results, read two rows of image pixels and process them. Before moving to the next row. This will reduce your image cache handling, and even make it posible to later convert the script into a 'pipelined image handling' program (like "stream").

Re: Read each pixel and neighbours with Image.pixelColor()

Posted: 2008-06-13T08:24:02-07:00
by LiloLilo
anthony wrote:For best results, read two rows of image pixels and process them. Before moving to the next row. This will reduce your image cache handling, and even make it posible to later convert the script into a 'pipelined image handling' program (like "stream").
OK, but in this case every row will be read twice. Do you mean that image cache will be smart enaught to detect that one row is already there and this will avoid to read it from the image. But how this will produce a benefit? I won't need to write back the row, because of it will be written to another image.

Thank you for help.

Re: Read each pixel and neighbours with Image.pixelColor()

Posted: 2008-06-14T20:52:44-07:00
by anthony
You can always use two image caches one for each row. That way you only need to read each row once.
You will however have to ask Magick about have two caches simultaneously.