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.
14 次查看(过去 30 天)
显示 更早的评论
% --- 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 个评论
Stephen23
2015-12-21
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.
采纳的回答
Stephen23
2015-12-21
编辑:Stephen23
2015-12-21
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!