Does the im2gray function give greater 'weight' to red than green and blue?

조회 수: 4(최근 30일)
I have the following colour coded echo strength image where the red indicates high levels of reflection, then yellow, then green:
I want to compare the actual image centroid with the weighted centroid and have done so using the following code:
clear all
% import the Image %
imdata = imread("RCS_Example3.bmp");
% Display the image %
% Convert to grayscale - Grayscale Images are 2D arrays because only
% need one value of intensity for each pixel %
RCSGray = im2gray(imdata);
title("RCS Gray Scale");
BW = RCSGray > 0;
title('Binary Image')
s = regionprops(BW,RCSGray,{'Centroid','WeightedCentroid'});
title('Weighted (red) and Unweighted (blue) Centroids');
hold on
numObj = numel(s);
for k = 1 : numObj
plot(s(k).WeightedCentroid(1), s(k).WeightedCentroid(2), 'r*')
plot(s(k).Centroid(1), s(k).Centroid(2), 'bo')
hold off
This produces the following figure (red star = weighted centroid, blue circle = actual centroid):
when converted to grayscale its hard to tell if the 'intensity' of the red spots on the original image is high and I want to know if the red spots are contributing a higher weighted value as they represent points of highest intensity reflection.
If this is correct, is there a way to work out how far apart the weighted and unweighted centroids are?
  댓글 수: 8
Isaak 2023년 3월 22일
Thanks @Stephen23 I think I understand what you're getting at. I'll need to go away and see if I can find the color map/ what scale the colours are assigned to from the software.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2023년 3월 22일
"I have the following colour coded echo strength image where the red indicates high levels of reflection, then yellow, then green"
What about gray and teal/aqua?
If you can, it's definitely best to get the original image values, not a pseudocolored image. Can you do that? If you can, it's easy. But WHY do you want the weighted centroid of this image when it looks like there are parts of the image that are clearly different and (perhaps) should not just be lumped in with the pixels of the entire image? I agree with Stephen that converting that to gray scale will not get you what you asked for (plus I'm not even sure what you're asking for is the proper thing to measure). What you would have to do, if you can't get the original image, is to use the colormap that was applied to this image to "undo" the pseudocoloring and get you back to the original values. It's what I do in the attached thermal image demo. What is your image of? It looks like maybe it's some kind of simulated inverse synthetic aperture radar image of a ship..
  댓글 수: 4
DGM 2023년 3월 22일
편집: DGM 2023년 3월 22일
If the software provides you with a colorbar, you may be able to use that to get a rough estimate of the colormap. At that point, IA's demo would work. If you have to take a screenshot, save it as PNG, not JPG, as capturing the ends of the colorbar is important for scaling, and JPG will skew them.
If there's a chance that the mapping is nonlinear, then you'd have to figure out what it is.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by