How can I write pixel label datastore to file?

1 view (last 30 days)
Hi, I am now trying with semantic segmentation by reffering to the steps in
mathworks.com/help/vision/ug/semantic-segmentation-with-deep-learning.html#mw_44be2a2e-ec6b-4a03-9470-ea945f74515e
But I faced problem when I want to show and save the predicted segmentation images from datastore to my computer. May I know what should I add on after 'pxdsResults'?
H='D:\data\desktop\New\testing_1';
K=dir(fullfile(H,'*.png'));
total_images=numel(K);
for n=1:total_images
f=fullfile(H,K(n).name);
I11=imread(f);
I12=imresize(I11,[300 300]);
I13=double(I12(:,:,1));
I14=medfilt2(I13);
L_1='D:\data\desktop\New\test_image';
path1=fullfile(L_1,K(n).name);
imwrite(I14/255,path1);
end
imdsTest = imageDatastore(L_1);
pxdsResults = semanticseg(imdsTest,net,"WriteLocation",tempdir);
I also tried to write the output into computer folder first, then save the output into pixel label datastore, but it failed also, the command window shows 'Not enough input arguments.'
H='D:\data\desktop\New\testing_1';
K=dir(fullfile(H,'*.png'));
total_images=numel(K);
for n=1:total_images
f=fullfile(H,K(n).name);
I11=imread(f);
I12=imresize(I11,[300 300]);
I13=double(I12(:,:,1));
I14=medfilt2(I13);
L_1='D:\data\desktop\New\test_image';
path1=fullfile(L_1,K(n).name);
imwrite(I14/255,path1);
testImage=I14;
I15 = semanticseg(testImage,net);
I16 = labeloverlay(testImage,I15);
figure(n);
L='D:\data\desktop\New\test_result';
path2=fullfile(L,K(n).name);
imwrite(I16,path2);
end
imdsTest = imageDatastore(L_1);
pxdsResults = pixelLabelDatastore(L);

Answers (0)

Community Treasure Hunt

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

Start Hunting!