Convert Input data and save as binary Image in MATLAB
2 views (last 30 days)
Show older comments
Stephen john on 10 Oct 2022
Commented: Med Future on 19 Oct 2022
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"
for imNum = 1:numImages
imData =data1(imNum,:); % get pattern
[~,Y] = meshgrid(1:imSz); % make a grid
% black and white image
BW = imbg;
% resize (from 1000x1000)
% convert to uint8 (0 255)
im = im2uint8(BW);
im = flipud(BW);
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!