Results 1 to 6 of 6

Thread: Recover the value of image in RGB

  1. #1
    Join Date
    Apr 2009
    Posts
    87

    Recover the value of image in RGB

    I use the OpenCV to manipulate images (RGB Color).I have a problem about the recovery of the value of all pixels in the image.

    value of a pixel in a given position
    Code:
    i = 0, / / line 0 
    j = 0, / / column 0 
    img = cvLoadImage ( "1.jpg", 1); 
    pixel = cvGet2D (img, i, j) / / read pixel column 25 line 10 
    / / pixel = cvGet2D (img, 1,1); 
    
    printf ( "value of the pixel blue:% f \ n", pixel.val [0]) / / blue value of pixel 
    printf ( "pixel green value:% f \ n", pixel.val [1]) / / blue value of pixel 
    printf ( "value of the pixel red:% f \ n", pixel.val [2]) / / blue value of pixel
    at this level, I'd like to know if the value of the pixel at position (0.0) is image1 pixel.val [0] + pixel.val [1] + pixel.val [2]

    the value of each pixel in the image


    to retrieve all the pixels of the image as a matrix I done this:
    Code:
    for (i = 0; i <height; i + +) (
    for (j = 0 j <width; j + +) ( 
    pixel = cvGet2D (img, i, j); 
    / / printf ( "value of the pixel blue:% f \ n", pixel.val [0]); 
    som2 = pixel.val [0] + pixel.val [1] + pixel.val [2]; 
    / / fprintf (fic_image, "% f% f% F", pixel.val [0], pixel.val [1], pixel.val [2]); 
    )
    )

    I see image 1 is different from image 2.
    Thank you in advance!

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: Recover the value of image in RGB

    A 24-bit color is defined by 8 bits red, 8 bits of green and 8 bits of blue. 0x123456 eg 0x12 means of red, green 0x34 and 0x56 blue.

    in the example the color is like this:

    color = red * green * 0x010000 + 0x000100 + 0x000001 * blue.

  3. #3
    Join Date
    Apr 2009
    Posts
    87

    Re: Recover the value of image in RGB

    I understand your example you mean that the value of the color corresponds to the value of the pixel?
    If yes then how to get the coefficients?

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: Recover the value of image in RGB

    Red is the most significant byte of so you must multiply the value by 65,536 or 256 * 256 or 0x10000.

    Green is the average weight of byte so you must multiply the value by 256 and 0x100.

    Blue is the low byte of so you must multiply its value by 1 or 0x1. So leave it as it is. These coefficients are always the same.you can use: color = red <<16 + green <<8 + blue

  5. #5
    Join Date
    Apr 2009
    Posts
    87

    Re: Recover the value of image in RGB

    One more thing if I have a pixel with the RGB value follows:
    R = 68
    V = 77
    B = 72

    What is the value of the color of that pixel?

  6. #6
    Join Date
    Jan 2009
    Posts
    199

    Re: Recover the value of image in RGB

    R = 68 = 0x44
    V = 77 = 0x4d
    B = 72 = 0x48
    therefore the pixel is 0x444d48 or 4476232 (72 * 1 + 77 + 256 * 68 * 65536) is just like what the pixel is stored in your image to the coordinates i, j.

Similar Threads

  1. Replies: 7
    Last Post: 15-02-2012, 05:29 AM
  2. Replies: 4
    Last Post: 09-08-2010, 02:51 PM
  3. How to recover deleted image in Nokia 5800
    By HarshaB in forum Portable Devices
    Replies: 5
    Last Post: 18-02-2010, 09:08 AM
  4. Replies: 4
    Last Post: 28-01-2010, 10:15 PM
  5. Replies: 3
    Last Post: 14-04-2008, 03:47 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,490,749.67522 seconds with 17 queries