how to solve subsrcipt indices problem in iswt operation

1 view (last 30 days)
I got the following error while computing inverse iswt operation.'Subscript indices must either be real positive integers or logicals.' I check the index by running 'whose variable' syntax and confirmed that the input index are logical. Please any one provide your valuable guidance.
image=imread('referenceframe.jpg');
image1=imread('currentframe.jpg');
image=imresize(image,[244 324]);
image1=imresize(image1,[244 324]);
% Do color conversion from rgb to hsv
x=rgb2hsv(image);
y=rgb2hsv(image1);
% Split the hsv component to h,s,v value
Hx = x(:,:,1);
Sx = x(:,:,2);
Vx = x(:,:,3);
Hy = y(:,:,1);
Sy = y(:,:,2);
Vy = y(:,:,3);
% Calculate a difference between this frame and the background.
dh=abs(Hx- Hy);
ds1=abs(Sx- Sy);
dv1=abs(Vx- Vy);
% Perform the 'swt'
[as,hs,vs,ds] = swt2(ds1,2,'haar');
[av,hv,vv,dv] = swt2(dv1,2,'haar');
%Compute the skewness value of 'swt of v'
sav1=skewness(av(:));
shv1=skewness(hv(:));
svv1=skewness(vv(:));
sdv1=skewness(dv(:));
%Perform the thresholding operation
for i = 1:244
for j = 1:324
b=(av(i,j)>=sav1);
c=(hv(i,j)>=shv1);
d=(vv(i,j)>=svv1);
e=(dv(i,j)>=sdv1);
recv = iswt2(b,c,d,e,'haar');
end
end
  4 Comments
KSSV
KSSV on 2 Jan 2018
Edited: KSSV on 2 Jan 2018
b,c,d and e are always 0's....you need to send some non zeros to iswt2.
SHOBA MOHAN
SHOBA MOHAN on 2 Jan 2018
I followed the algorithm given in the paper for detecting and removing shadows. I have done till shadow detection thresolding part and shadow removal yet to be done. Can you please check whether i coded correctly the algorithms? what is wrong with that code? provide your suggestion.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 2 Jan 2018
In newer versions, the code instead complains that the first input was logical when real finite double values were expected.
  3 Comments
Walter Roberson
Walter Roberson on 2 Jan 2018
Edited: Walter Roberson on 2 Jan 2018
refimage=imread('referenceframe.jpg');
curimage1=imread('currentframe.jpg');
refimage=imresize(refimage,[244 324]);
curimage1=imresize(curimage1,[244 324]);
% Do color conversion from rgb to hsv
x=rgb2hsv(refimage);
y=rgb2hsv(curimage1);
% Split the hsv component to h,s,v value
Hx = x(:,:,1);
Sx = x(:,:,2);
Vx = x(:,:,3);
Hy = y(:,:,1);
Sy = y(:,:,2);
Vy = y(:,:,3);
% Calculate a difference between this frame and the background.
dh=abs(Hx- Hy);
ds1=abs(Sx- Sy);
dv1=abs(Vx- Vy);
% Perform the 'swt'
[as,hs,vs,ds] = swt2(ds1,2,'haar');
[av,hv,vv,dv] = swt2(dv1,2,'haar');
%Compute the skewness value of 'swt of v'
sav1=skewness(av(:));
shv1=skewness(hv(:));
svv1=skewness(vv(:));
sdv1=skewness(dv(:));
%Perform the thresholding operation
b = 0 + (av >= sav1);
c = 0 + (hv >= shv1);
d = 0 + (vv >= svv1);
e = 0 + (dv >= sdv1);
recv = iswt2(b,c,d,e,'haar');
imagesc(recv)
SHOBA MOHAN
SHOBA MOHAN on 2 Jan 2018
Thanks Walter. Now, the iswt syntax works. I have included the threshold for shadow removal as per algorithm given in the attached article also given the same code here.
sas=skewness(as(:));
shs=skewness(hs(:));
svs=skewness(vs(:));
sds=skewness(ds(:));
f=(as>=sas);
g=(hs>=shs);
h=(vs>=svs);
z=(ds>=sds);
k = 0 + (b&f);
l = 0 + (c&g);
m = 0 + (d&h);
n = 0 + (e&z);
recs= iswt2(k,l,m,n,'haar');
de_shadow1_hsv=cat(3,dh,recs,recv);
de_shadow1=hsv2rgb(de_shadow1_hsv);
de_shadow1=rgb2gray(de_shadow1);
I am attaching the 'recs','recv' and output image for your kind reference. It is noticed that shadow presents in the'output image'. Can you suggest me why shadow presents in output though we applied shadow removal threshold.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!