[問題] if內的變數出了問題已回收
因為剛開始接觸matlab
寫程式時發現問題,
找了很久bug,但一直找不出來
所以提出來問一下版友
for i=1:H-1
for j=1:W-1
a=img_stego(i+1,j);
b=img_stego(i,j);
c=img_stego(i,j+1);
d=img_stego(i+1,j+1);
%計算a c的max和min值
if(a>c)
temp_max=a;
temp_min=c;
else
temp_max=c;
temp_min=a;
end
temp3=temp_max;
temp4=temp_min;
if (d==255)
temp1=temp_max;
temp2=temp_min;
if (b<=temp_min)
img_cover(i+1,j+1)=temp_max;
elseif (b>=temp_max)
img_cover(i+1,j+1)=temp_min;
else
img_cover(i+1,j+1)=a+c-b;
end
end
end
end
只要看temp1~4就可以了
照理來說 temp3=temp1 temp4=temp2
可是不知道什麼原因
一進到if這判斷式時
temp3 =/=temp1 temp4 =/=temp2
反而temp1和temp2會相同
我一直找不太出來原因
是我有用法用錯了嗎
--
ξ
○-
<(╯ 這 , 就是人生呀。
■)﹥
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.134.25.125
→
11/30 22:11, , 1F
11/30 22:11, 1F
→
11/30 22:15, , 2F
11/30 22:15, 2F
→
11/30 22:28, , 3F
11/30 22:28, 3F
→
11/30 22:29, , 4F
11/30 22:29, 4F
→
11/30 22:30, , 5F
11/30 22:30, 5F
→
11/30 22:31, , 6F
11/30 22:31, 6F
→
11/30 22:35, , 7F
11/30 22:35, 7F
→
11/30 22:39, , 8F
11/30 22:39, 8F
應該不是if(b...)那裡的問題,因為剛才有測試過,把整段註解掉
只留下if(d=255) end 然後temp1 和temp2都留著 但值一樣不對
您說少一個end是指?
※ 編輯: cbolong 來自: 140.134.25.125 (11/30 22:42)
→
11/30 22:44, , 9F
11/30 22:44, 9F
打文章時不小心刪掉一個end
測試時是有end
→
11/30 22:45, , 10F
11/30 22:45, 10F
※ 編輯: cbolong 來自: 140.134.25.125 (11/30 22:48)
→
11/30 22:48, , 11F
11/30 22:48, 11F
→
11/30 22:50, , 12F
11/30 22:50, 12F
這是我的m和圖檔 因為找了很久 一直不明白原因orz
※ 編輯: cbolong 來自: 140.134.25.125 (11/30 22:54)
※ 編輯: cbolong 來自: 140.134.25.125 (11/30 23:46)