Image MATLAB:批量处理图像并保存这些图像。我该怎么办?
对不起,我是个新手。我试着复制代码找到了 以获得相同的结果,但不起作用(故障矿井)。我无法理解Image MATLAB:批量处理图像并保存这些图像。我该怎么办?,image,matlab,image-manipulation,Image,Matlab,Image Manipulation,对不起,我是个新手。我试着复制代码找到了 以获得相同的结果,但不起作用(故障矿井)。我无法理解saveas如何理解必须保存的图像。我已经读到,saveas想要一个句柄和文件名作为输入,在我在上面链接中提供的代码中,我没有看到这些参数: saveas(sprintf('img%d.tif',num_picture)) 以下是我的代码的一小部分: % Here a loop that transform aeach image inside the variable(cell array) 'im
saveas
如何理解必须保存的图像。我已经读到,saveas
想要一个句柄和文件名作为输入,在我在上面链接中提供的代码中,我没有看到这些参数:
saveas(sprintf('img%d.tif',num_picture))
以下是我的代码的一小部分:
% Here a loop that transform aeach image inside the variable(cell array) 'immages'
for z = 1:length(immages) %images is a cell array contained the matrices of 100images
temp = immages{z}; %temp means temporary, that is the image to process
for i = 1:I % begin of cycle that process each pixel of the image(tmp)
for j = 1:J
if temp(i,j) == 0
temp(i,j) = 115;
else
temp(i,j) = 140;
end
end
end
cd(finalDest); %move into the directory whre I want to save the new image
figure;
imshow(temp);
saveas(sprintf('img%d.tif',z)); % HOW CAN I SAVE THE CURRENT IMAGE(TEMP) INSIDE 'FINALDEST'?
cd(initialDest); %return to the folder where the original images are contained
end
我在使用SAVEAS时遇到此错误第55行:需要图形或方框图的句柄和文件名。
非常感谢。您说得对,
saveas
需要一个图形句柄作为第一个参数,您可以更改一个:
figure;
与
及
或者使用gcf
获取当前图形的句柄:
saveas(gcf, sprintf('img%d.tif',z));
如果您只想保存temp
矩阵上的信息(而不是整个图),则应使用:
saveas(h, sprintf('img%d.tif',z));
saveas(gcf, sprintf('img%d.tif',z));
imwrite(temp,sprintf('img%d.tif',z));