Thread: Find a pixel?

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    13

    Find a pixel?

    okay, theres a picture, i want the app to find a blue pixel, if there a blue pixel...

  2. #2
    Registered User
    Join Date
    Mar 2009
    Posts
    399
    It depends on the file format ...

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    13
    you mean jpeg , png... ? ummm.... lets say png

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Quote Originally Posted by geniusisgenius View Post
    you mean jpeg , png... ? ummm.... lets say png
    Well, you'll need to either parse the PNG format or else find a library that can.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  5. #5
    Making mistakes
    Join Date
    Dec 2008
    Posts
    476
    Also depends on what you define as blue. [0, 0, 255] or anything with b > 128 (for example)?

  6. #6
    Registered User
    Join Date
    May 2010
    Posts
    13
    it is [0,0,255] (blue is just an example, it can be another color but ill just have to modify that

  7. #7
    Making mistakes
    Join Date
    Dec 2008
    Posts
    476
    Then you can load the image, create a mapped [0, 0, 255] and search for it in the file... Of course, it gets harder with different formats and palettes etc... Maybe use a library to convert it into an array of color bytes?

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    If you display the pic on the monitor, then you might have other options.

    Every OS knows where the video memory buffer starts and stops. Find that address range, and you can check it directly for a blue value.

    No, I haven't done it before, but the program "Dead Pixel Buddy", uses that technique, I'm sure, since there is no picture file being searched.

    I don't believe any of these "check the format" answers, are what you want. That's a deep ditch to get out of, imo.

  9. #9
    Making mistakes
    Join Date
    Dec 2008
    Posts
    476
    Of course I reckon it might not be very easy to project a full image onto the screen and scan the video buffer.

    You can use SDL and SDL_image (the latter one if you want something other than .bmp). It's straightforward.

  10. #10
    Registered User
    Join Date
    May 2010
    Posts
    13
    can't you help me with a code? makes it way easier. Ok let me be clearer 2 lines arent pretty enough:

    i want to develop an app, and it loads an image, and scans all the pixels,if the app found example a blue pixel it will say: blue point detected, example.

  11. #11
    Registered User
    Join Date
    Aug 2005
    Posts
    266
    you need to pick a format, all formats are different .. find its library to work with such files and work with it to get a color byte array.

    i recommend libpng

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. find() command
    By kiros88 in forum C Programming
    Replies: 2
    Last Post: 08-06-2009, 04:37 PM
  3. Replies: 5
    Last Post: 04-16-2004, 01:29 AM
  4. linked list recursive function spaghetti
    By ... in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2003, 02:53 PM
  5. how do u find 2nd largest number??
    By juancardenas in forum C Programming
    Replies: 8
    Last Post: 02-14-2003, 08:28 AM