Errors using imwrite "Unable to determine the file format from the filename" I am trying to splice together the name of a new image file but dont understand why imwrite isnt working.
20 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Marshall
el 21 de Dic. de 2015
% --- Executes on button press in Save.
function Save_Callback(hObject, eventdata, handles)
% hObject handle to Save (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global y
newname = get(handles.newname,'String')
display(y);
tif = '.tif';
filename = [newname tif];
display(filename);
imwrite(y,'default',newname,'tif')
Heres hat I have so far. Not really sure how to solve this issue with the way I am going about it. I though thtat if the filename had the .tif written in it it may recognize the fileformat, but I guess not. Any suggestions? Also on another note, how can I create somesort of dropdown menu to specify the pathway for this image file? Thanks
1 comentario
Stephen23
el 21 de Dic. de 2015
This time I fixed your code formatting for you. In future please do it yourself by first selecting your code text, and then clicking the {} Code button. The default text that clicking the button produces is not markup.
Respuesta aceptada
Stephen23
el 21 de Dic. de 2015
Editada: Stephen23
el 21 de Dic. de 2015
You could try reading the imwrite documentation. At the top of the page there is a list of the accepted syntaxes:
Syntax
imwrite(A,filename)example
imwrite(A,map,filename)example
imwrite(___,fmt)
imwrite(___,Name,Value)
Whereas what you are trying to use is:
imwrite(y,'default',newname,'tif')
What does 'default' mean? It does not seem to fit any of the permitted syntaxes. Where did you get this from? I don't see 'default' listed as any of the permitted input arguments. When I try your code with an image it produces the same error:
>> X = imread('parula_0.png');
>> newname = 'test';
>> imwrite(X,'default',newname,'tif')
??? Error using ==> imwrite at 435
Unable to determine the file format from the filename.
but when I remove 'default' from your code it works fine:
>> imwrite(X,newname,'tif')
with a new file created correctly. This is why reading the documentation is useful.
Also note that your code creates a new name string in the variable filename, but that you do not use this variable. Perhaps you really meant to call this:
imwrite(y,filename,'tif')
0 comentarios
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!