I=process(x,y,z) % "process" is the sub problem called in the main program to produce some output
Imshow(I) % displays the image
imwrite(I,path) % it does not save that image
instead it gives me the error that "the file format is not found from file name"
i tried using imsave % it works but i have to give the location and hence not suitable for large data
i have to save some 120 images that is not possible using imsave
someone pls help me how to save the image I which is displayed using imshow

4 commentaires

Stephen23
Stephen23 le 2 Déc 2014
A good point from Mohammad Abouali that deserves to be closer to the question:
Do NOT use path as a variable name, as this is the name of the function path .
Although MATLAB lets you define variable and function names that are the same as inbuilt functions, this can cause all sorts of awkward problems and really is best avoided.
RAMESH MUNIRATHINAM
RAMESH MUNIRATHINAM le 3 Déc 2014
thanks for your help
path is not the function name, i have given the path where it is to be saved
imwrite (I,location) % it works fine in other programs
but in this program imwrite (I,location) % displays the error as "file format is not found"
is there anything to be done additionally in the subprogram without disturbing its original function or variables
Stephen23
Stephen23 le 3 Déc 2014
Modifié(e) : Stephen23 le 3 Déc 2014
Please read my comment again: I did not write that you defined path as the function name, I wrote that path is being used as a variable name. However, note that both of these cases are best avoided, as path is an inbuilt function and shadowing inbuilt functions can cause problems that you really want to avoid.
RAMESH MUNIRATHINAM
RAMESH MUNIRATHINAM le 4 Déc 2014
thanks will try and inform you

Connectez-vous pour commenter.

 Réponse acceptée

Stephen23
Stephen23 le 3 Déc 2014
Modifié(e) : Stephen23 le 3 Déc 2014

0 votes

According the imwrite documentation , there are several accepted input combinations:
imwrite(A,filename,fmt)
imwrite(X,map,filename,fmt)
imwrite(...,filename)
or online:
imwrite(A,filename)
imwrite(A,map,filename)
imwrite(___,fmt)
In your case you are only supplying one image A and the filename. The documentation states that in this case " imwrite(A,filename) writes image data A to the file specified by filename, inferring the file format from the extension. imwrite creates the new file in your current folder". Note that filename (which should not be named path, as you have done) must therefore include the image file extension. Without this, I also get exactly the same error as you:
>> load spine
>> imshow(X,map)
>> imwrite(X,map,'temp1')
??? Error using ==> imwrite at 435
Unable to determine the file format from the filename.
>> imwrite(X,map,'temp1.png')
>>
Note how I specify the image file format in filename, and it does not throw an error. You also need to specify the image file format, either within filename or in the fmt variable.
And do not use path as the name of your filename variable.

5 commentaires

RAMESH MUNIRATHINAM
RAMESH MUNIRATHINAM le 4 Déc 2014
thanks for your help will try and inform you
RAMESH MUNIRATHINAM
RAMESH MUNIRATHINAM le 6 Déc 2014
hello stephen
i tried the code the image was written perfectly one problem is that if i use multiple images then only the last image is being saved
i used imwrite(Ig,var,.jpg) var= varying file names
the code doesnt take the names
then i dont know wat mapping value should i give for gray scale image
Stephen23
Stephen23 le 6 Déc 2014
Modifié(e) : Stephen23 le 6 Déc 2014
You should first confirm that those names really are different. Consider using either
  • disp(var)
  • a debugging breakpoint
If you read the imwrite documentation you will find that the map input is optional.
RAMESH MUNIRATHINAM
RAMESH MUNIRATHINAM le 6 Déc 2014
confirmed it is varying
RAMESH MUNIRATHINAM
RAMESH MUNIRATHINAM le 6 Déc 2014
thank you finally i made it. now there is another problem occurring for me
if c=1:4
c=1 update(process)
c=2 update(process)
c=3 update(process)
c=4 update(process) end
i have split the image into 4 subplots so that it will be easy for comparison
each time the value of c varies the image gets updated
i have used the imwrite code outside the loop, then also the total updated image is not been written in folder
only the image corresponding to condition c=4 is written inside the folder
please kindly help so that i could see some progress in the work
once again thanks for your help for the past

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Read, Write, and Modify Image dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by