Create multiple image from raw data in MATLAB

Hello everyone, I hope you are doing well. I have the dataset of shape 1x77564 .
I have write the following code which take first 1000 samples and convert it into image. but when i convert it into first 1000 some values not included in the image.
How can I create image which include all the values of 1x77564 in 1x1000 sample shape. Or How can i create mutliple image
[row, column] = size(incomingdata);
for eachrow=1:row
if column==1000
outputdataset(eachrow,:)=incomingdata(eachrow,:);
else
targetsize = 1000;
sizeofincomingdata = column;
nrep = targetsize / sizeofincomingdata;
fullrep = floor(nrep);
leftover = targetsize - fullrep * sizeofincomingdata;
outputdataset(eachrow,:)=[repmat(incomingdata(eachrow,:), 1, fullrep), incomingdata(1:leftover)];
% outputdataset(eachrow,:)= dataset;
end
end
% dataDirectory = fullfile('C:\Users\DELL\Documents\MATLAB\Examples\R2021b\phased\ModClassificationOfRadarAndCommSignalsExample\NewDataset\DatasetGeneration\IncomingDataset');
% disp("Data file directory is " + dataDirectory);
%% 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);

9 Commenti

77564 is not a multiple of 1000 so how do you plan on handling that?
I suggest you use buffer if you have the Communications Systems Toolbox; it is a useful routine that should probably be included in basic MATLAB.
@Image Analyst we can repeat it to make 80000. it will change for other dataset so we need to make it a modular.
@Walter Roberson i dnt understand How can i used in my code.
buffered = buffer(incomingdata, 1000);
for K = 1 : size(buffered,2)
thisdata = buferred(:,K);
%work with thisdata
end
You do not need to manage the indexing yourself other than the indexing by column.
buffer() pads with zeros, so in the last column, the elements after row 564 would be 0.
@Walter Roberson But 0 is a number my algo will failed if i append 0 at the end. is there is any other option?
Define what you want to have happen for the last 564 entries of your vector of length 77564
@Walter Roberson I want it to be the replicate of the last values to complete the vector length. it should be modular to if any other vector have comes like 17340 , then it also make it 18000 by repeating the last values.
Replicate how many last values? In the 17340 case would you replicate the last 340 one full time and then nearly but not quite another full time to reach 1000? And if it had been 17001 you would replicate that 001 as needed?

Accedi per commentare.

Risposte (0)

Prodotti

Release

R2022a

Richiesto:

il 13 Ago 2022

Commentato:

il 14 Ago 2022

Community Treasure Hunt

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

Start Hunting!

Translated by