Convert Input data and save as binary Image in MATLAB

1 回表示 (過去 30 日間)
Stephen john
Stephen john 2022 年 10 月 10 日
コメント済み: Med Future 2022 年 10 月 19 日
Hello, I hope you are doing well. I have the following dataset in which first row consists of one shape and second contain another shape.. I want to make a binary image
the data has shape of 1x1000 for first row and same for 2nd row. How can i do it in MATLAB. I have used the following code but it does not work. Can any body help me in that
[numImages, lenImage] = size(data);
imSz = 1000; % assuming images are 1000x1000
imbg = false(imSz); % background "color"
imfg = ~imbg(1,1); % forground "color"
imSizeOut=[1000 1000];
for imNum = 1:numImages
imData =data1(imNum,:); % get pattern
[~,Y] = meshgrid(1:imSz); % make a grid
% black and white image
BW = imbg;
BW(Y==imData)=imfg;
% resize (from 1000x1000)
BW=imbinarize(imresize(uint8(BW),imSizeOut));
% convert to uint8 (0 255)
im = im2uint8(BW);
SE=strel('disk',2);
BW=imdilate(im,SE);
im = flipud(BW);
end
  3 件のコメント
Stephen john
Stephen john 2022 年 10 月 11 日
@Benjamin Thompson I have updated the code. The first row is the first shape of the object which i want to save as binary image. and second row has other object shape.
Please tell me which you want me to update
Med Future
Med Future 2022 年 10 月 19 日
@Image Analyst Can you please look into this?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by