How to convert raw value shape into image
조회 수: 2 (최근 30일)
이전 댓글 표시
I have the dataset into shape of 1x1000 which is name as outputdataset
After that i have a code which convert this data to binary image form of shape of 1000x10000. which i converted it into the image the shapes does not remain the same , the shape changes the pixels overlapped on one another.
How can i modified the code to make this shape similar to Original Shape. my image dimision will remain the same 1000x10000. and when i resized it into 227x227 the shape will be shown.
Can anybody help me
I have attached the shape of the image as 10000size image and 227x227 image
%% create grayscale shapes that resemble the data
[numImages, lenImage] = size( outputdataset);
imSz = 1000; % assuming images are 1000x1000
imbg = false(10000,1000); % background "color"
imfg = ~imbg(1,1); % forground "color"
imSizeOut=[10000 1000]; % ImageSize
for k= 1:numImages
imData = round( outputdataset(k,:)); % get pattern
[~,Y] = meshgrid(1:1000,1:10000); % make a grid
% black and white image
BW = imbg;
BW(Y==imData)=imfg;
valueestimation=imbinarize(imresize(uint8(BW),imSizeOut));
% convert to uint8 (0 255)
valueestimationimage = im2uint8(valueestimation);
% resize (from 1000x1000)
SE=strel('disk',2);
BW=imdilate(BW,SE);
BW=imbinarize(imresize(uint8(BW),imSizeOut));
% convert to uint8 (0 255)
imoriginalestimate = im2uint8(BW);
imoriginal = flipud(imoriginalestimate);
im=imresize(imoriginal,[227 227]);
im = repmat(im,[1 1 3]);
end
댓글 수: 0
답변 (1개)
Image Analyst
2022년 7월 31일
Resizing will either subsample the line away or else change the value and blur it. To get it sharp again, just threshold it
im = im > 0;
or just create it as 227 x 227 in the first place.
댓글 수: 10
Image Analyst
2022년 8월 1일
Where are you doing that? You forgot to include that code. Even if you do later use im, you're just overwriting im every single iteration so at the end you'll just have one im and it will be the latest image.
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!