Error using cd Argument must contain a string
显示 更早的评论
I am getting this error while executing this code :
w = cd;
cd(DIAGPATH);
imwrite(image,[eyeimage_filename,'-normal.jpg'],'jpg');
cd(w);
% end diagnostics
%replace NaNs before performing feature encoding
coords = find(isnan(polar_array));
polar_array2 = polar_array;
polar_array2(coords) = 0.5;
avg = sum(sum(polar_array2)) / (size(polar_array,1)*size(polar_array,2));
polar_array(coords) = avg;
can anybody please explain it to me..need help. thankyou in advance.
采纳的回答
im_path = fullfile(DIAGPATH, [eyeimage_filename,'-normal.jpg'] );
imwrite(image,im_path,'jpg');
Then you do not need any cd calls at all: this is a much faster and more robust way to write code. You will also find that the variable DIAGPATH is not a string, which it needs to be.
7 个评论
hey thank you for ur positive reply. after making modification to my code :
% write out rings overlaying original iris image
im_path = fullfile('D:\matlab',[eyeimage_filename,'-normal.jpg'] );
imwrite(image,im_path,'jpg');
% end diagnostics
%replace NaNs before performing feature encoding
coords = find(isnan(polar_array));
polar_array2 = polar_array;
polar_array2(coords) = 0.5;
avg = sum(sum(polar_array2)) / (size(polar_array,1)*size(polar_array,2));
polar_array(coords) = avg;
following errors are occurring now can u please help me in this -
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
Error in normaliseiris (line 167)
im_path = fullfile('D:\matlab',[eyeimage_filename,'-normal.jpg'] );
You need to check the variable eyeimage_filename: is it a string? What size is it? Tell me exactly the output of these commands:
class(eyeimage_filename)
size(eyeimage_filename)
ans =
double
ans =
150 200
these are the outputs.
@nisha: Do you see, that the variable "eyeimage_filename" does not contain a file name?
@jan can't i just pass the variable which may containing eyeimage_filename instead of passing 'Img_89_1_1.jpg'.
my code :
clear all;
close all;
clc;
I=imread('Img_89_1_1.jpg');
figure();imshow(I);
title('INPUT IMAGE');
grey_img=rgb2gray(I);
figure();imshow(grey_img);
title('Gray image');
edge_image=edge(grey_img,'canny');
figure();imshow(edge_image);
title('CANNY IMAGE');
figure; imshow(edge_image);
[ci,cp,out]=thresh(grey_img,38,50);
figure();imshow(out);
class(I)
size(I)
[polar_array, polar_noise] = normaliseiris(out, 84, 101,47,...
81, 106, 12,I, 302, 24);
for eyeimage_filename = I it prompt following error :
ans =
uint8
ans =
150 200 3
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
Error in normaliseiris (line 167)
im_path = fullfile('D:\matlab',[eyeimage_filename,'-normal.jpg'] );
but when i put eyeimage_filename= 'Img_89_1_1.jpg', an image is created in my matlab folder like this.
please help !!


"can't i just pass the variable which may containing eyeimage_filename instead of passing 'Img_89_1_1.jpg'."
No, you can't.
An image is not a filename, an image is a numeric array of data, usually of class double or uint8.
A filename is a string, such as your string 'Img_89_1_1.jpg'.
You cannot use an array of numeric data for a filename. This makes no sense. Read the documentation for imwrite, or fullfile, or any other function that uses filenames: they all use strings. There is no mention of numeric arrays. Numeric arrays do not contain meta-data such as their origin filename, the date of creation or modification, your cousin's telephone number, or any other meta-data. Surprisingly, a numeric array contains numeric data!
To write an image to file you need two pieces of information: the image data (a numeric array) and the filename (a string). What do you possibly hope to achieve by giving imwrite two images arrays and no filename? Try this:
imwrite(I,im_path,'jpg');
That is all there is to it.
Nisha. Can you help me out with iris recognition code. I'm getting same error as you got in findcircle.m functions.
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Convert Image Type 的更多信息
标签
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
