I am getting an error as "Check for incorrect argument data type or missing argument in call to function 'exp'." can anyone help me out?

1 view (last 30 days)
a=imread("house.jpeg");
outimage=a;
k=.001;
iterations=30;
lambda=.25;
[m,n]=size(a);
rowc=[1:m];
colc= [1:n];
rown= [1 1:m-1];
cole= [1 1:n-1];
rows= [1:m m];
colw= [1:n m];
for i = 1: iterations
deltaN= outimage(rown,colc)- outimage(rowc,colc);
deltaE= outimage(rowc,cole)- outimage(rowc,colc);
fluxN= deltaN * exp(-(1/k)*abs(deltaN));
fluxE= deltaE * exp(-(1/k)*abs(deltaE));
outimage= outimage + lambda*(fluxN-fluxN(rows,rowc) + fluxE- fluxE(rowc,colw));
end

Answers (2)

Steven Lord
Steven Lord on 17 Dec 2021
Most likely your image data is of an integer type. The exp function is not defined for the integer types.
one = int8(1);
y = exp(one)
Check for incorrect argument data type or missing argument in call to function 'exp'.
There are few integer values that when used as the input to exp result in an integer valued result.
Convert your data to double before calling exp on it.
  1 Comment
yanqi liu
yanqi liu on 19 Dec 2021
deltaN= double(outimage(rown,colc)- outimage(rowc,colc));
deltaE= double(outimage(rowc,cole)- outimage(rowc,colc));
fluxN= deltaN * exp(-(1/k)*abs(deltaN));
fluxE= deltaE * exp(-(1/k)*abs(deltaE));
but
outimage= outimage + lambda*(fluxN-fluxN(rows,rowc) + fluxE- fluxE(rowc,colw));
may be dimension error

Sign in to comment.


Image Analyst
Image Analyst on 19 Dec 2021
Here are some improvements but I don't really know what the vectors are for and what the deltaN and deltaE represent. Are they the vertical and horizontal gradients like you'd get from imgradientxy()?
grayImage = imread("peppers.png"); % Read in image.
imshow(grayImage, []);
% Convert to double so we can do subtractions and get negative numbers.
grayImage = double(grayImage);
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels == 3
% Convert to gray scale
grayImage = rgb2gray(grayImage);
end
outimage = grayImage;
k = .001;
iterations = 30;
lambda = .25;
% Define some vectors. I have no idea what these are for.
rowc = [1 : rows];
colc = [1 : columns];
rown = [1, 1:rows-1];
cole = [1, 1:columns-1];
rows = [1:rows, rows];
colw = [1:columns, rows];
for k = 1: iterations
fprintf('Starting iteration %d of %d.\n', k, iterations)
% Probably need to index rown, colc, etc. below.
deltaN = outimage(rown,colc)- outimage(rowc,colc);
deltaE = outimage(rowc,cole)- outimage(rowc,colc);
fluxN = deltaN * exp(-(1/k)*abs(deltaN));
fluxE = deltaE * exp(-(1/k)*abs(deltaE));
outimage= outimage + lambda*(fluxN-fluxN(rows,rowc) + fluxE- fluxE(rowc,colw));
end

Categories

Find more on Image Processing and Computer Vision in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!