Page 1 of 1

extract pixel block magick++

Posted: 2006-04-20T14:24:22-07:00
by mrjvak
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...

Posted: 2006-04-20T17:15:39-07:00
by magick
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 ).