Page 1 of 1

[SOLVED]Writing a white image: after a certain size it gives me a "pixels are not authentic" error

Posted: 2017-08-03T04:21:59-07:00
by edrid
I'm playing around with Magick++ prior to a uni project I've to do in C++.
In particular, as of now, I'm implementing some kernel image processing. Long story short, after certain operations (i.e. exporting, doing the convolution on the 2D std::vectors, etc.) I want to set the pixel of a completely white image to those i calculated with the convolution, so I do the following:

Code: Select all

for(unsigned int i = 0; i < elaboratedImage.size().height()-1; i++){
        for(unsigned int j = 0; j < elaboratedImage.size().width()-1; j++){
            elaboratedImage.pixelColor(i,j, Color(reds.at(i).at(j), greens.at(i).at(j), blues.at(i).at(j), 0));
            //std::cout << "i = " << i << "\tj = " << j << std::endl;
        }
    }
However, after the 0th iteration of the outer for-loop and 479th iteration of the inner for-loop it throws me the following error:
terminate called after throwing an instance of 'Magick::ErrorCache'
what(): ImMagPlayground: pixels are not authentic `#FFFFFF' @ error/cache.c/QueueAuthenticPixelCacheNexus/3961
The image is 640x480, that I created using

Code: Select all

Image elaboratedImage(Geometry(640,480), Color(QuantumRange, QuantumRange, QuantumRange));
, so a white image of the specified dimensions (I do display and it shows correctly).

However it seems like the library, at a certain point, considers this image as a 480x480, in fact, if I do the for(s), both using the height it works (obviously it only shows me a square of the processed image and a white bar on the right (the remaining 640-480 not set pixels)).

I also tried to manually set one pixel in the outer range (e.g. pixel(1,500)) and it gives me the same error..

I'm sure it's a simple error.. however I'm not getting it..

Re: Writing a white image: after a certain size it gives me a "pixels are not authentic" error

Posted: 2017-08-03T11:39:49-07:00
by snibgo
pixelColor, like most functions, expects the coordinates in the order x then y. Not y then x.

Re: Writing a white image: after a certain size it gives me a "pixels are not authentic" error

Posted: 2017-08-04T02:37:41-07:00
by edrid
Oh my gosh.. yeah, that was the problem.. sorry and thanks :shock: