Info

この質問は閉じられています。 編集または回答するには再度開いてください。

explanation of two instructions

1 回表示 (過去 30 日間)
ABDASALAM  EMZEKA
ABDASALAM EMZEKA 2016 年 2 月 19 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
can you explain to me the instructions in the attached photo sorry i am too beginner ( please ) thanks

回答 (1 件)

Matthew Eicholtz
Matthew Eicholtz 2016 年 2 月 19 日
It is difficult to tell without knowing more about certain variables that aren't defined in the photo you provided (e.g. Ne, L), but the first snippet uses a for-loop to go through a structure (maybe the output of regionprops?) and draws rectangles on the current figure based on the "BoundingBox" field.
The second snippet, is locating the subscripts in some variable L that equal n, then using the imagen (I'm not sure what that function is or where it comes from?) to generate an image, which is shown by the function imshow.
Does that help at all?
  1 件のコメント
ABDASALAM  EMZEKA
ABDASALAM EMZEKA 2016 年 2 月 19 日
編集済み: Walter Roberson 2016 年 2 月 19 日
%%firstly thanks for your reply
%%this is the whole code : -
%%Image segmentation and extraction
%%Read Image
imagen=imread('image_a.png');
%%Show image
figure(1)
imshow(imagen);
title('INPUT IMAGE WITH NOISE')
%%Convert to gray scale
if size(imagen,3)==3 % RGB image
imagen=rgb2gray(imagen);
end
%%Convert to binary image
threshold = graythresh(imagen);
imagen =~im2bw(imagen,threshold);
%%Remove all object containing fewer than 8 pixels ( in addition to the defult number of 2dimensional image is 8 and three dimensional is 26
imagen = bwareaopen(imagen,8);
pause(1)
%%Show image binary image
figure(2)
imshow(~imagen);
title('INPUT IMAGE WITHOUT NOISE')
%%Label connected components
[L Ne]=bwlabel(imagen);
%%Measure properties of image regions
propied=regionprops(L,'BoundingBox');
hold on
%%Plot Bounding Box
for n=1:size(propied,1)
rectangle('Position',propied(n).BoundingBox,'EdgeColor','g','LineWidth',2)
end
hold off
pause (1)
%%Objects extraction
figure
for n=1:Ne
[r,c] = find(L==n);
n1=imagen(min(r):max(r),min(c):max(c));
imshow(~n1);
pause(0.5)
end

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by