Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 11-05-2009
Member
 
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!
Reply With Quote
  #2  
Old 11-05-2009
Member
 
Join Date: May 2008
Posts: 2,008
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.
Reply With Quote
  #3  
Old 11-05-2009
Member
 
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?
Reply With Quote
  #4  
Old 11-05-2009
Member
 
Join Date: May 2008
Posts: 2,293
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
Reply With Quote
  #5  
Old 11-05-2009
Member
 
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?
Reply With Quote
  #6  
Old 11-05-2009
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Recover the value of image in RGB"
Thread Thread Starter Forum Replies Last Post
Showing grey image instead of the Google TV in full screen and not getting image while setting up my TV source in New Logitech Revue Diedrick Technology & Internet 7 15-02-2012 05:29 AM
Burn image or iso file to BD-RE using Windows Disc Image Burner Udayachal Windows Software 4 09-08-2010 02:51 PM
How to recover deleted image in Nokia 5800 HarshaB Portable Devices 5 18-02-2010 09:08 AM
Is it possible to sort image gallery when an image is uploaded in Cute Editor? KAILEY Software Development 4 28-01-2010 10:15 PM
iTunes.exe - Bad Image - ksuser.dll is not a valid Windows image Omar Windows Security 3 14-04-2008 03:47 AM


All times are GMT +5.5. The time now is 08:19 AM.