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.
Read each pixel and neighbours with Image.pixelColor()
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Read each pixel and neighbours with Image.pixelColor()
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").
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Read each pixel and neighbours with Image.pixelColor()
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.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").
Thank you for help.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Read each pixel and neighbours with Image.pixelColor()
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.
You will however have to ask Magick about have two caches simultaneously.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/