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 个)

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 个评论

can u please tell what is thismin and loopIndex please
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
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 个评论

In such cases i want to display the first image
Do you mean as you are running through the loop you wan to display the image with the current lowest error?
YES THOMAS
Why couldn't you just keep track of which has the lowest error like I showed you how to do?
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