Azzera filtri
Azzera filtri

how to solve subsrcipt indices problem in iswt operation

2 visualizzazioni (ultimi 30 giorni)
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 Commenti
KSSV
KSSV il 2 Gen 2018
Modificato: KSSV il 2 Gen 2018
b,c,d and e are always 0's....you need to send some non zeros to iswt2.
SHOBA MOHAN
SHOBA MOHAN il 2 Gen 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.

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 2 Gen 2018
In newer versions, the code instead complains that the first input was logical when real finite double values were expected.
  3 Commenti
Walter Roberson
Walter Roberson il 2 Gen 2018
Modificato: Walter Roberson il 2 Gen 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 il 2 Gen 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.

Accedi per commentare.

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by