in reply to Re^5: Perl Image Analysis
in thread Perl Image Analysis

I loaded the image using Opera and used it's zoom function to blow the image up 1000%. It is then fairly obvious that the "white" area immediately surrounding the black squares is full of slightly off-white pixels, including #f2f2f2, #f1f1f1, #ededed, #f6f6f6, #f5f5f5, etc. This is probably an artifact of the JPEG 'lossy' compression system, though it could also be an artifact of the drawing program you used to constuct it.

Update: Actually, looking at it again (looking at my lcd from an oblique angle), the black isn't entirely black either. bThere are several pixels in both squares that are variously #0f0f0f, #030303, #0c0c0c etc.

Redo your image using the non-lossy .png or .tiff formats. If the artifacts go away, it was the JPEG compression biting you. If they don't, it is your drawing program that may be attempting to antialias something. Either look for a configuration option to turn that off or use a 'dumb' graphics editor (like mspaint.exe) that doesn't attempt to do anything clever :) (The had to be some advantage to paint didn't there :)

Also, be wary of what program you use to zoom the image. For example, Ifranview will resample the image as you zoom it unless you explicitly turn that option (view->properties->view->Use resample) off. This results in the edges of the squares getting antialiased, and the corners getting rounded as the image is zoomed.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^7: Perl Image Analysis
by lparsons42 (Novice) on Oct 06, 2006 at 21:14 UTC
    Yes, I see now what you mean. I didn't expect that jpg conversion would hurt a greyscale image like that.
    I then retried this using a tiff file instead. I found that the GD library can read jpgs and pretty much only jpgs. It errors out on PNG, GIF, and TIFF.
    Looks like I'm going back to using the Imager module so I can read TIFFs.
    Thanks again all!

      GD can certainly read .png & .gif. I'm not sure about tiff.

      For .gifs you need a fairly recent version (post the expiry of the .gif patent), but I use GD to create and manipulate .pngs all the time, and going back at least 4 years.

      What are the errors you are getting when you try to load a .png?


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Actually, a closer inspection revealed that I had an earlier line in the script that I had forgotten that told it I was looking at Jpg files:
        my $MyImage = GD::Image->newFromJpeg($file, 0);
        I found that of course if I changed that line instead to
        my $MyImage = GD::Image->newFromPng($file, 0);
        That it will then happily read PNG files. Had I remembered having set GD to read Jpeg files, I probably would have realized that one earlier. Of course, the errors telling me that the file wasn't Jpeg probably should have clued me in, as well...

        For .gifs you need a fairly recent version (post the expiry of the .gif patent)

        Or of course a really old version before the GIF support was removed over the patent concerns :-)

        /j\