Save- path for image using the function "imwrite()"

Hi
when I use the imshow() function, I know that I have the image that I want to display in one of the files in the *MATLAB path.
For instance, when I take a picture with my webcam, I want to save it by using imwrite.
where has the image been written to?
Matar Maoz

 채택된 답변

Walter Roberson
Walter Roberson 2011년 2월 13일

1 개 추천

The image gets written to the current directory by default. You can specify an explicit path when you imwrite()

댓글 수: 3

matar maoz
matar maoz 2011년 2월 13일
thanks. i the file, but I still can't use it for later in the code.
for example, I want to imread() the picture
X = imread('squmatar3.png');
but I get:
*File "squmatar3.png" does not exist.*
if it is in the current directory, why can't I imread() or imshow() it ?
MATAR MAOZ
Jan
Jan 2011년 2월 13일
If the file exists in the current directory, IMREAD *can* read it. Please check: "exist('squmatar3.png', 'file')".
Sounds like you may have switched directories between.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jan
Jan 2011년 2월 13일

2 개 추천

IMWRITE writes to the current folder, so these two commands are equivalent:
image = rand(100, 100, 3);
imwrite(image, 'File.png')
imwrite(image, fullfile(cd, 'File.png'))
The later method can be used to specifiy the wanted directory.

댓글 수: 5

matar maoz
matar maoz 2011년 2월 13일
I don't know if the syntax is correct for the second row, because i get an error:
*??? Error using ==> imwrite at 363
Too few input arguments*
I also didnt find anything in the help about it.
I'd be glad to get a bit more help :)
Matar Maoz
imwrite() needs the first argument to be the image matrix to write.
Jan
Jan 2011년 2월 14일
I've inserted [image] in the example. To get help about IMWRITE, type "help imwrite".
ayushi
ayushi 2016년 7월 21일
suppose if we want to check that if in a variable "R" some image exist like "Image1" then imshow(image2) how to do this?
if ~isempty(R) && ndims(R) < 4 && (isnumeric(R) || islogical(R))
disp('R contains an image');
end
Or did you mean that R contains the name of a file that contains an image?
if exist(R, 'file')
try
imfinfo(R);
%if we got here then R does name an image. So for some reason now we are supposed to display a different image
imshow(image2);
catch
%R names a file that is not an image
end
else
%R does not name a file
end

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

질문:

2011년 2월 13일

댓글:

2016년 7월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by