displaying image

i have a code
for j1 = 1:size(A1_20,3)
for j = 1:J
% loop thru subbands
for s1 = 1:2
for s2 = 1:3
w{j}{s1}{s2} =A1_20(:,:,j1);
y1 = idualtree2D(w, J, Fsf, sf);
Er= mean2((single(x) - single(y1)).^2);
final_col2{j1}=Er;
end
end
end
end
in this i have 20 images in y1 and for each i have found error,now i want to display image which has minimum error,please help

답변 (2개)

Image Analyst
Image Analyst 2012년 4월 6일

1 개 추천

I think you know the basic code for keeping track of the max or min where you set the global min to some huge number (say, inf)
globalMin = inf;
and then in the loop, get the value you want the min of, and do something like
if thisMin < globalMin
% This (the current) min is less than our lowest min.
% Save this min as our new global min and keep track of the index.
% Keep track of j1, j, s1 and s2 if you need to.
globalMin = thisMin;
indexAtGlobalMin = loopIndex;
end
The code is similar if you want to find the max, just use -inf and ">" instead of "<". In your case, of course, thisMin is your "Er" variable, and you might call globalMin "lowestError" or something descriptive like that.

댓글 수: 3

kash
kash 2012년 4월 7일
can u please tell what is thismin and loopIndex please
Image Analyst
Image Analyst 2012년 4월 7일
thisMin is your "Er" variable. The loopIndex is j1, j, s1 and s2 - whichever you want to keep track of.
kash
kash 2012년 4월 11일
if Er < globalMin
% This (the current) min is less than our lowest min.
% Save this min as our new global min and keep track of the index.
% Keep track of j1, j, s1 and s2 if you need to.
globalMin = thisMin;
indexAtGlobalMin = j1;
end
i sthis correct ,then how to display image
Thomas
Thomas 2012년 4월 6일

0 개 추천

do you have your 20 error values in final_col2? assuming you do..
final_col2=rand(20,1) % I have created random data for error
final_col2 =
0.75
0.26
0.51
0.70
0.89
0.96
0.55
0.14
0.15
0.26
0.84
0.25
0.81
0.24
0.93
0.35
0.20
0.25
0.62
0.47
>>q = min(final_col2)
q =
0.14
>>p =find(final_col2==(min(final_col2)))
p =
8.00
In the above example you will find that image 8 has the minimum error..

댓글 수: 5

kash
kash 2012년 4월 6일
In such cases i want to display the first image
Thomas
Thomas 2012년 4월 6일
Do you mean as you are running through the loop you wan to display the image with the current lowest error?
kash
kash 2012년 4월 6일
YES THOMAS
Image Analyst
Image Analyst 2012년 4월 6일
Why couldn't you just keep track of which has the lowest error like I showed you how to do?
Thomas
Thomas 2012년 4월 6일
Yes, Image Analyst's answer is the best one in this case... Just keep track of the minimum inside the loop.
@ image analyst: +1 for your answer

이 질문은 마감되었습니다.

질문:

2012년 4월 6일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by