필터 지우기
필터 지우기

how to solve subsrcipt indices problem in iswt operation

조회 수: 2 (최근 30일)
SHOBA MOHAN
SHOBA MOHAN 2018년 1월 2일
댓글: SHOBA MOHAN 2018년 1월 2일
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
KSSV
KSSV 2018년 1월 2일
편집: KSSV 2018년 1월 2일
b,c,d and e are always 0's....you need to send some non zeros to iswt2.
SHOBA MOHAN
SHOBA MOHAN 2018년 1월 2일
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.

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

채택된 답변

Walter Roberson
Walter Roberson 2018년 1월 2일
In newer versions, the code instead complains that the first input was logical when real finite double values were expected.
  댓글 수: 3
Walter Roberson
Walter Roberson 2018년 1월 2일
편집: Walter Roberson 2018년 1월 2일
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 2018년 1월 2일
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.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by