associate a string to a pixel
Hi everybody, i have an image with many colors,one for pixel and I would associate a string to every pixel to specify the color's name;is there a way to do this? Thank you.
Hi everybody, i have an image with many colors,one for pixel and I would associate a string to every pixel to specify the color's name;is there a way to do this? Thank you.
I think you have predefined string for each pixel value, if I right you can solve this by accessing each pixel in the image using following piece code
for(int i=0; i<src->height; i++)
{
for(int j=0; j<src->width; j++)
{
CvScalar pix=cvGet2D(src,i,j); // pix.val[0]->Blue channel
// pix.val[1]->Green channel
// pix.val[2]->Red channel
}
}
By comparing each pixel value you can find the colours of corresponding pixel. I hope this is what your are looking for.
i'm using c++,my image is Mat type and cvGet2D doesn't accept it as an argument!!however,once i do this,how can i associate a string? e.g. : first pixel is R:0 G:1 B:91 and the string is "very very dark blue"
For C++ see this link http://stackoverflow.com/questions/7899108/opencv-get-pixel-information-from-mat-image. So do you have per-defined string for each pixel combination?
Asked: 2012-12-12 06:03:06 -0600
Seen: 180 times
Last updated: Dec 12 '12
Extracting a vector of pixel values across multiple frames
Reading pixel values from a frame of a video
How to operate on each pixel of a cv2.cv.Mat with a 3 x 3 matrix?
Accessing pixel value always return same value
extract a vector of pixels from a frame
android ndk level access to camera video stream/pixels