How to convert raw value shape into image

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

回答 (1 件)

Image Analyst
Image Analyst 2022 年 7 月 31 日

1 投票

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 件のコメント

Stephen john
Stephen john 2022 年 7 月 31 日
編集済み: Stephen john 2022 年 7 月 31 日
@Image Analyst Where i can apply this threshold?
Recreating into 227x227 is not good option because my pixel values lies in between 1 to 10000. How can i make a image in which above 227x227
Stephen john
Stephen john 2022 年 7 月 31 日
@Image Analyst But the main issue is that the value is the single pixel represent a single value , as you see in the outputdataset file.
Stephen john
Stephen john 2022 年 7 月 31 日
@Image Analyst Have you understand my problem now
Image Analyst
Image Analyst 2022 年 7 月 31 日
Sorry, b ut I don't. Why do you create "im" and then not do anything with it? Is making a 227x227 image a good approach or not - I'm getting conflicting answers from you.
Stephen john
Stephen john 2022 年 8 月 1 日
@Image Analyst I resize the image to give it to trained squeezenet model for classification
Stephen john
Stephen john 2022 年 8 月 1 日
編集済み: Stephen john 2022 年 8 月 1 日
@Image Analyst My original data is raw form which values varies from 1 to 10000 i convert this values to image format and and trained the squeezenet deep learning network. Now i am taking real data and convert it into image. but when it resizes the pixel values are overlapped on one another. to gives as wrong prediction.
Image Analyst
Image Analyst 2022 年 8 月 1 日
You're not using im to make a prediction, or at all. You're just creating it and then ignoring it.
Stephen john
Stephen john 2022 年 8 月 1 日
@Image Analyst i am using this image after this for prediction. is there is any way to solve this problem?
Image Analyst
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.
Stephen john
Stephen john 2022 年 8 月 1 日
@Image Analyst After making im, i repeat the matrix and make shape of 227x227x3 to classify it using sequeezenet model.
im=imresize(imoriginal,[227 227]);
im = repmat(im,[1 1 3]);
YTest = classify(net,im);

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

カテゴリ

ヘルプ センター および File ExchangeDeep Learning Toolbox についてさらに検索

製品

リリース

R2022a

質問済み:

2022 年 7 月 31 日

コメント済み:

2022 年 8 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by