Info

This question is closed. Reopen it to edit or answer.

error in writing an image to folder

2 views (last 30 days)
kash
kash on 21 Feb 2012
Closed: MATLAB Answer Bot on 20 Aug 2021
I have a code ,in which the image is not writing to a folder
clc;
close all;
pathname ='E:\ebcot\mri'
dirlist = dir( [pathname '*.jpg'] );
pickind='jpg';
f1=fullfile('E:\ebcot\sample25\')
if (exist(f1) == 0)
mkdir (f1);
end
for m2 = 1:length(dirlist)
map = pink(90);
i = imread([pathname, dirlist(m2).name]);
a=i;
singvals=20;
dvalue=double(a);
[u,s,v] = svds(dvalue, singvals);
if isa(a,'uint8')
im = uint8(u * s * transpose(v));
end
if isa(a,'uint16')
im = uint16(u * s * transpose(v));
end
if isa(a,'double')
im = (u * s * transpose(v));
end
return;
pickind='jpg'
strtemp=strcat('E:\ebcot\sample25\',int2str(m2),'.',pickind);
imwrite(im,strtemp);%title('ebcot low pass frames ');
end
I have 15 jpg images in mri folder,please help

Answers (1)

Image Analyst
Image Analyst on 21 Feb 2012
I think the "return" statement right before the imwrite() might be a huge factor in why it never gets to the imwrite().
By the way, use it like this to check the folder:
f1='E:\ebcot\sample25\'; % No need for fullfile() here.
if ~exist(f1, 'dir')
mkdir (f1);
end
Don't assign anything to i, which is the imaginary variable, because you'll override it. It's generally not recommended.
You might use fullfile() instead of this "[pathname, dirlist(m2).name]" or the strcat(). You can also use sprintf() instead of strcat, or simply square brackets.
  2 Comments
kash
kash on 21 Feb 2012
CAn u please tell how to use
fullfile() instead of this "[pathname, dirlist(m2).name]" or the strcat(). or simply square brackets.
kash
kash on 21 Feb 2012
I tried
f1='E:\ebcot\sample25\'; % No need for fullfile() here.
if ~exist(f1, 'dir')
mkdir (f1);
end
and changed the variable i ,but still not working

This question is closed.

Community Treasure Hunt

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

Start Hunting!