i find centre of mass, but that's not what me need
How to detect bright spot on image?
20 views (last 30 days)
Show older comments
How find coordinates bright spot and placed dot on this? please could you help me
For example, we have pic(attach.) and need find centre this figure(centre of the image and centre of the figure on image its diffrent things, because they could be shifted relatively each other), we need find ROI with max intensity, who contained ~90%(10% is a noise and e.t.c.) all intensity. ROI containing max intensity include centre of the figure who i need to find. How i can do this? help me please.
(sorry for my bad English)
3 Comments
KSSV
on 16 Nov 2018
Attach the original image without a mark at the center. So that users can work on the image.
Accepted Answer
KSSV
on 16 Nov 2018
Edited: KSSV
on 16 Nov 2018
I = imread('11.JPG') ;
I1 = rgb2gray(I) ;
[y,x] = find(I1==255) ;
%% Fit circle to the data (x,y)
n=length(x); xx=x.*x; yy=y.*y; xy=x.*y;
A=[sum(x) sum(y) n;sum(xy) sum(yy) sum(y);sum(xx) sum(xy) sum(x)];
B=[-sum(xx+yy) ; -sum(xx.*y+yy.*y) ; -sum(xx.*x+xy.*y)];
a=A\B;
% Center of cricle
xc = -.5*a(1);
yc = -.5*a(2);
R = sqrt((a(1)^2+a(2)^2)/4-a(3));
% Plot
imshow(I)
hold on
plot(xc,yc,'*b')
Instead of fitting a circle, you can straight away, use mean of x and y also.
8 Comments
Image Analyst
on 23 Nov 2018
Just do
halfWindowWidth = 100; % Whatever size you want.
% row1 = round(yCentroid - halfWindowWidth);
row2 = row1 + 2 * halfWindowWidth - 1;
col1 = round(xCentroid - halfWindowWidth);
col2 = col1 + 2 * halfWindowWidth - 1;
croppedImage = rgbImage(row1:row2, col1:col2, :)
More Answers (1)
Image Analyst
on 22 Nov 2018
You could do it based on just the largest blob, which will be at the center.
binaryImage = bwareafilt(binaryImage, 1); % Extract largest blob.
props = regionprops(binaryImage, 'Centroid'); % Find centroid (not weighted by gray level).
xCentroid = props.Centroid(1);
yCentroid = props.Centroid(2);
hold on;
plot(xCentroid, yCentroid, 'b+', 'MarkerSize', 50); % Plot cross over centroid.
2 Comments
Image Analyst
on 23 Nov 2018
Use bwareaopen() instead.
Better yet, upgrade to R2018b since your version is 6 years old.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!