this is the error iam getting
The file name or URL argument must be a character vector or string scalar.
Error in imread (line 342)
[source, fmt_s, extraArgs, was_cached_fmt_used] = parse_inputs(cached_fmt, varargin{:});
im = double(imread(image))
clc;
clear all;
D = 'C:\Users\PRL\Desktop\barathfocus\for-matlab-testonly';
S = dir(fullfile(D,'*.tif')); % pattern to match filenames.
for k = 1:numel(S)
F = fullfile(D,S(k).name);
I = double(imread(F));
a = bodekke(I);
end
function[addition] = bodekke(image)
im = double(imread(image))
bd = [-1 0 1]
cbd = conv2(im,bd)
squaredcbd = cbd.^2
addition = sum(squaredcbd(:))
imshow(cbd)
end

댓글 수: 2

a = bodekke(F);
barath V
barath V 2020년 2월 6일
편집: barath V 2020년 2월 6일
yes,is working thanks bhaskar.
but i dont understand why it works.
i have passed the image to variable I.
and i call the function with image I it should work.
why it is working if i call by using its name

댓글을 달려면 로그인하십시오.

 채택된 답변

Shunichi Kusano
Shunichi Kusano 2020년 2월 6일

0 개 추천

The argument for imread must be file location. "image" in the function is an array.
HTH

댓글 수: 5

barath V
barath V 2020년 2월 6일
can u pls tell me which line should i cahnge?
Sorry for my rough reply. The first line in the function is problematic. As commented,
a = bodekke(F)
will work.
barath V
barath V 2020년 2월 6일
편집: barath V 2020년 2월 6일
yes,is working thanks.
but i dont understand why it works.
i have passed the image to variable I.
and i call the function with image I it should work.
why it is working if i call by using its name.
Stephen23
Stephen23 2020년 2월 6일
편집: Stephen23 2020년 2월 6일
"and i call the function with image I it should work."
Not according to the imread documentation, which states that imread requires a filename as its first input argument. In your function bodekke you call imread, but in your original code what is its input argument? (hint: an image array, and not a filename as it requires).
"why it is working if i call by using address"
Because imread requires a filename as its first input argument.
It appears that you are getting confused by the fact that you have called imread twice, once outside the function (correctly with a filename) and once inside the function (incorrectly with a numeric array). You can either call imread outside the function (and pass an image array) or inside the function (and pass the filename), but doing both makes no sense.
barath V
barath V 2020년 2월 6일
thanks i understood.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

제품

릴리스

R2018b

질문:

2020년 2월 6일

댓글:

2020년 2월 6일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by