i am trying to calculate linear index of fuzziness of an image using this formula:
i have to see a positive y value according to the paper. But i see a negative value, so i think i am doing something wrong. here is my try. and my output_image
q=(pi/2)*(1-output_image/255); %I is output image and 255 is maximum gray level. output_iamge is 288*384 double and grayscale image
y= sum(sum(min(q,1-q)))/(width*height); %M*N is width*height
Related
I was working with this picture in Matlab to detect the color of the circles. This is a 512 by 512 jpeg image.
I am finding the centers of circles using imfindcircles, then I am taking the R, G, B components of some points near the center of each circle to detect color.
But, I am confused because, for both the red and white circles, I find that the R, G, B components are same [239 227 175].
I am new to image processing, so can anyone explain what's actually happening here.
The centers output of imfindcircles gives the coordinates of the centers in x/y coordinates and you need to index into your image using row/column coordinates so you need to be sure to reverse the two columns when indexing into the image
centers = imfindcircles(IM);
center1 = IM(centers(1,2), centers(1,1),:);
center2 = IM(centers(2,2), centers(2,1),:);
Presumably you are not doing this because you are instead sampling pixels from the background which obviously result in the same RGB values for the centroids.
Update
It appears that actual issue is that you are casting the location of the centroids to a uint8 to make it an integer value so you can then use it as an index. The maximum integer representable by uint8 is 255 and the number of rows and columns in your image is large than 255 (and so are the centroids) so they will get truncated to 255 resulting in the wrong pixel being sampled.
Rather than using uint8, just use round to round the centroids to their nearest integers
cX = round(centers(n_c,1));
cY = round(centers(n_c,2));
I want to plot an image. Therefor I have a matrix with the dimensions wxhx3, where w and h are the resolution (width, height respectively). The third dimension contains the vector of rgb-color.
So image(1,1,1) is the red component of Pixel(1,1), image(1,1,2) is the green and image(1,1,3) the blue one.
Now my question is, how can I plot an image with this given matrix?
If I want to use image(..), I have to define a colormap and recompute the indices because image(...) requires a wxhx1 matrix.
Can anyone help my?
Matlab images display functions (image, imshow, imagesc) take either data that is formatted into an image format (uint8 for 8-bit image and uint16 for 16-bit image) or data of double type for values in the [0,1] range.
So if you have value in the range [0,255] (or [0,65535] for 16-bit image) you can try :
imshow(uint8(matrix))
or
imshow(uint16(matrix))
If have you values in the range [0,1] you can try :
imshow(double(matrix))
Or, the least recommendable, if your values do not fit those cases you can try :
imshow(double(matrix/max(matrix(:))))
EDIT: from #rayryeng comment.
I have a BW image. I have to calculate the average intensity of that image. For this I have to store individual intensity value of all pixels of that image then calculate average intensity. In this calculation I have to count only the non zero pixel's intensity value (full black pixel i.e. intensity value zero should not take in calculation). How can I do that?
You can try this, but this doesn't work if any columns of the image are all 0!
im=imread('imageBW.jpg');
intensity=mean(sum(im)./sum(im~=0));
I have been trying to get HSV values of few RGB pixels using the following code
im = imread('peppers.png'); %// example image
c = [12 146 410]; %// column coordinates of desired pixels
r = [104 156 129]; %// row coordinates of desired pixels
pixels = impixel(im,c,r); %// rgb values of pixels
hsv = rgb2hsv(pixels); %// convert to hsv
hue = hsv(:,1); %// hue is first column of hsv
But I get an error, Valid colormaps cannot have values outside the range [0,1].
Can someone please tell me what is wrong with my code?
The range of the RGB colormap must be [0,1] (double) for rgb2hsv to work; your problem is the pixels matrix color range goes from 0 to 255 (int). You have to find a way to fix this. im2double might help.
See the rgb2hsv documentation for details.
Also, I would recommend the use of imfinfo to know the kind of image you are dealing with to then act accordingly in your code.
I need to transform thermographic images into gray-scale to detect temperature variation using matlab.
I tried to use the inbuilt function rgb2gray(), but it's inefficient for my image database, so I tried to compute the formula for this, using correlation between colours and temperature and then interpolating it, but then will be it possible to get the efficient mathematical formula?
My formula:
i=0.29 * rgb_img(:,:,1) + 0.59 * rgb_img(:,:,2) + 0.11 *
rgb_img(:,:,3);
and
i=0.6889*rgb_img(:,:,1)+.5211*rgb_img(:,:,2)+.4449*rgb_img(:,:,3)+72.8;
but both of these didn't help.
sample images are:
http://www.google.com/imgres?imgurl=http://www.breastthermography.com/images/AP-Breast-Case-2.jpg&imgrefurl=http://www.breastthermography.com/case_studies.htm&h=199&w=300&tbnid=48Yto8Y8RtRPjM:&zoom=1&docid=PX1nchTaFQpa3M&ei=ftVdVIatNZCQuATptoLgCA&tbm=isch
There is small vertical multicolor bar at the right edge of images. It represents palette which has been used for Gray->Color transformation. If you can no access to exact formula for this thansform, you can try approximation: extract 1-pixel wide vertical line to array from bottom to top.
If resulting array length is not equal to 256, adjust the range (interpolate if needed). Now you have map: Color -> Index of this Color = 8-bit Gray Value. Use it to construct grayscale image. If you need absolute temperature, you can adjust range to 280-350 (in 0.1 degrees) or another suitable range.
The formula used in JFIF is
Y = 0.299R +0.587G +0.114B
That's fairly close to what you have. So I do know what you mean when you say what you were using did not work.