extract pixel block magick++

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply

extract pixel block magick++

Post by mrjvak » 2006-04-20T14:24:22-07:00

Hi everyone,
I am a beginner, can you please advice me onhow to extract a block of pixels in an efficient way? I acutally want to scan with a window over the image. In pseudo code:

for(int y=0; y<image.rows(); y+= template.height ) {
for(int x=0; x<image.columns(); x+= template.width ) {
pxl_block = image.getPixels( x+template.width, y+template.height )

What is fastest - read the whole image to a pickel paket a scan the the pixel packet or scan the image to make small pixelpackets?

many thanks in advance...

User avatar
Site Admin
Posts: 10980
Joined: 2003-05-31T11:32:55-07:00

Post by magick » 2006-04-20T17:15:39-07:00

The most efficient way to get pixels is to get one or a few scanlines with getConstPixels(). If you want to update the pixels, use getPixels(). Assume your neighborhood kernel is 5 x 5. You will want to call getConstPixels() as getConstPixels( 0, y, columns, 5 ).

Post Reply