Hello everyone.I would like to ask you how to extract the data of a local area of a picture. The code I wrote is shown below. Please help me correct the mistakes. Thank you all.

1 Ansicht (letzte 30 Tage)
BW21=imread('m1.jpg');
% stats = regionprops(BW21,'Area','Centroid');%binaryImage
%
% %props = regionprops(BW21, 'Perimeter');%binaryImage
[labeledImage, numRegions] = bwlabel(BW21);%binaryImage
props = regionprops(labeledImage, 'Area','Centroid','Perimeter');
% Compute all the areas.
allAreas = [props.Area];
% Display each blob in its own figure.
for k = 1 : numRegions
thisRegion = ismember(labeledImage, k);
figure;
imshow(thisRegion);
drawnow;
end
%%%Data extraction of the first region on the image
data=imbinarize(BW21);%'image.jpeg'
result=edge(data);
figure,imshow(result);
[r,c]=find(result==1);
figure,plot(c,r,'.');
%%%Data extraction for the first area
for i=1:1:912
for j=1:1:1312
if BW31(i,j)~=1
BW31(i,j)=0;
end
end
end
x = linspace(1,912,912)';
y = linspace(1,1312,1312)';
contourf(y, x, BW31 ,20);
colorbar;
xlabel('x');
ylabel('y');
axis equal
data=imbinarize(BW31);%'image.jpeg'
result=edge(data);
figure,imshow(result);
[r,c]=find(result==1);
figure,plot(c,r,'.');
%
% Data extraction for the second area
%
BW32=bwlabel(BW21);
for i1=1:1:912
for j1=1:1:1312
if BW32(i1,j1)~=1
BW32(i1,j1)=0;
end
end
end
x1= linspace(2,912,912)';
y1 = linspace(2,1312,1312)';
contourf(y1, x1, BW32 ,20);
colorbar;
xlabel('x1');
ylabel('y1');
axis equal
data1=imbinarize(BW32);%'image.jpeg'
result1=edge(data1);
figure,imshow(result1);
[r1,c1]=find(result1==1);
figure,plot(c1,r1,'.');
...
%

Antworten (3)

Sulaymon Eshkabilov
Sulaymon Eshkabilov am 20 Mai 2021
Is that what you are trying to get?
D = imread('BW.jpeg');
MYdata=imbinarize(D);
figure(1)
imshow(MYdata);
R=edge(MYdata);
figure,imshow(R);
[Edge,C]=find(R==1);
figure(2)
plot(C,Edge,'k.'), title('Separated local area pictures')
  1 Kommentar
Wesley
Wesley am 20 Mai 2021
Thank you very much for your kind reply. My idea is to extract the data from the first area. The second, the third, and the area behind it don't matter. I'd like to ask you this question. Thank you very much.

Melden Sie sich an, um zu kommentieren.


Sulaymon Eshkabilov
Sulaymon Eshkabilov am 20 Mai 2021
Maybe here you can find some good help:
https://www.mathworks.com/matlabcentral/answers/76528-measurement-in-images-image-analysis?s_tid=srchtitle

Image Analyst
Image Analyst am 20 Mai 2021
You say "My idea is to extract the data from the first area. The second, the third, and the area behind it don't matter." By "area" I assume you mean "region". I have no idea what "data" means. You can get the area, the cropped region, individual uncropped blobs using ismember(), and lots of other stuff from regionprops().
But you have
% Compute all the areas.
allAreas = [props.Area];
so you're getting all the areas of all the blobs, if "area" is what you meant by "data". Otherwise, explain what "data" means to you. And define what you mean by "first" since blobs have varying size and are at verying locations.
  1 Kommentar
Wesley
Wesley am 20 Mai 2021
Thank you very much for your reply. In this way, the extracted coordinate data is in one block. I want to extract the coordinates of the edge curve of a single small area. For example, like the picture I sent below, the data of such a small area is saved individually. Thank you very much for your help.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Visual Exploration finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by