函数使用Matlab将扩展名更改为图像 [英] function to change the extension to an image using matlab
本文介绍了函数使用Matlab将扩展名更改为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个读取图像并更改其扩展名的函数,我希望它能够识别其原始名称并仅更改扩展名,因此我获得了该名称并随后进行了连接,但是我不明白为什么它不起作用.感谢您的帮助.
I am trying to make a function that read an image and change its extension, I want it recognize its original name and change just the extension so I get the name and later concatenate but i can't understand why is not working. I appreciate any help.
function salida = cambioFormatoImagen(x)
y = imread(x);
[pathstr,name,ext] = fileparts(x);
nombre=name;
concatena=strcat(nombre,'.jpg')
imwrite(y,concatena);
imshow(y);
end
>> cambioFormatoImagen
Error using cambioFormatoImagen (line 2)
Not enough input arguments.
推荐答案
我的错误是不对该函数使用任何输入参数. 我应该使用类似的东西:
My mistake was to not use any input argument to the function. I should have used something similar to:
salida = cambioFormatoImagen('image.png')
这篇关于函数使用Matlab将扩展名更改为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文