Find Objects And Define circle
이전 댓글 표시
Dear ;
I have simulation lock-in thermography data. And on image i want to find circle but images(data) not clear to see circle and i could not find way to solve this problem.
I already wrote some code but it is working just on one data but on the rest it is not accuretly.
Do you have any suggestion or could you show me a way to solve my problem?
In the attached you can see some component image of data .
it is my code :
clc
close
A = PCT_20_1;
subplot(1,3,1)
imshow(A)
title('A')
C = colormap; % Get the figure's colormap.
L = size(C,1);
% Scale the matrix to the range of the map.
Gs = round(interp1(linspace(min(A(:)),max(A(:)),L),1:L,A));
H = reshape(C(Gs,:),[size(Gs) 3]); % Make RGB image from scaled.
subplot(1,3,2)
image(H) % Does this image match the other one?
title('IMAGE (MxNx3)')
H;
D = segmentImage(H);
[B,L] = bwboundaries(D,'noholes');
subplot(1,3,3)
imshow(label2rgb(L, @jet, [.5 .5 .5])),title('colour') %add colour to
title('morphology')
hold on % waited for image
for k = 1:length(B)
boundary = B{k}; %choose coordinat of 'k' using by (X,Y)
plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2);
end
below shows image segmenter code I use to find circle :
function [BW,maskedImage] = segmentImage(RGB)
%segmentImage Segment image using auto-generated code from imageSegmenter app
% [BW,MASKEDIMAGE] = segmentImage(RGB) segments image RGB using
% auto-generated code from the imageSegmenter app. The final segmentation
% is returned in BW, and a masked image is returned in MASKEDIMAGE.
% Auto-generated by imageSegmenter app on 09-Mar-2020
%----------------------------------------------------
% Convert RGB image into L*a*b* color space.
X = rgb2lab(RGB);
% Auto clustering
sz = size(X);
im = single(reshape(X,sz(1)*sz(2),[]));
im = im - mean(im);
im = im ./ std(im);
s = rng;
rng('default');
L = kmeans(im,2,'Replicates',2);
rng(s);
BW = L == 2;
BW = reshape(BW,[sz(1) sz(2)]);
% Clear borders
BW = imclearborder(BW);
% Clear borders
BW = imclearborder(BW);
% Fill holes
BW = imfill(BW, 'holes');
% Create masked image.
maskedImage = RGB;
maskedImage(repmat(~BW,[1 1 3])) = 0;
end
댓글 수: 2
Image Analyst
2020년 3월 11일
Are the "circles" always in the same place, such that you can use a fixed template/mask? Or can they occur anywhere scattered around the image? Do they always occur in a grid, such that you can get average vertical and horizontal profiles to find peaks? Will there always be a signal, or is it possible that the signal could be missing, like the whole thing just looks like a uniform background? For a robust solution, these need to be answered, otherwise we're solving the question for just one specific image and that algorithm might not perform well over the wider variety of appearances you might encounter.
Mekan Aydemir
2020년 3월 11일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!