image.display() displaying old image

Roland Roberts <[email protected]> Mon, 21 Apr 2008 13:47:45 -0400
Newsgroups gmane.comp.video.image-magick.devel
Message-ID <[email protected]>
I'm new at using ImageMagick's C++ API, and per the mailing list 
desciptions, I'm posting here because this question seems to arcane for 
normal users (but maybe my arcane threshold is too low).

I've created a new image using the C++ api and then use getPixels(), set 
the image data, then syncPixels() and last display().  The iamge starts 
out as black and when I display it, it is still black.  If I insert a 
image.write("foo.png") before the display(), the file is correct, but 
the display() is still solid black.

I'm attaching the complete program which is my first baby steps in 
trying to write something that does image alignment using the 
phase-correlation method.  For practice images, I used a 174x174 black 
image with a white dot in the middle and another one with the dot 
shifted 10 pixels right and down.  The code works, finding the shift at 
(10,10), but this intermediate image, which was supposed to be just for 
diagnostics in seeing the effect of applying a Hamming window shows up 
black.

The critical part that is confusing me is in the image2fft routine here:

    ColorGray gray(0.0);
    Image copy(image.size(), gray);
    copy.type(GrayscaleType);
    copy.depth(image.depth());
    copy.modifyImage();
    PixelPacket *npixels = copy.getPixels(0, 0, width, height);

    for (int i = 0; i < width*height; i++) {
        gray.shade(abs(in[i]));
        *(npixels+i) = gray;
    }
    copy.syncPixels();
    copy.write("/tmp/junk.png");
    // WTF!?  Why does this not display the image it just wrote?
    copy.display();

The array in is declared as complex<double> *in and allocated 
dynamically based on the input image size.  The array is set based on 
the grayscale values of the input image.

What magic[k] am I missing?

roland

-- 
		       PGP Key ID: 66 BC 3B CD
Roland B. Roberts, PhD                             RL Enterprises
[email protected]                            6818 Madeline Court
[email protected]                           Brooklyn, NY 11220

_______________________________________________
Magick-developers mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-developers