Finding max intensity pixel in image doesnt work in code
7 次查看(过去 30 天)
显示 更早的评论
Hello, I am a beginner so I can only work with basic code for now. The assignment was to use 2 pictures, get the difference between the two, then find the max intensity pixel, but as you can see from the percentage marks, I have tried many things and none have worked. If anyone has a suggestion please feel free to respond.
colormap('gray');
%displays plane 1 BMP
planes1pic = imread('planes1.bmp');
subplot( 4, 1, 1);
imagesc(planes1pic);
axis off
title('BEFORE');
%displays planes 2 BMP
planes2pic = imread('planes2.bmp');
subplot(4, 1, 2);
imagesc(planes2pic);
axis off
title('AFTER');
PROBLEM CODE BEGIN:
%finds the difference between the planes by subtratction, and finds the max
planesDiff = (planes1pic - planes2pic);
subplot(4, 1, 3);
imagesc(planesDiff);
axis off
title('DIFFERENCE');
hold on
%[rowsMax , colsMax] = find(planesDiff == max(planesDiff(:)));
% maxplanesDiff = max(max(planesDiff()));
%[xx , yy] = find(planesDiff == maxplanesDiff);
%plot(xx , yy, '.r');
%lol = find(planesDiff == max(max(planesDiff)));
%plot(lol , '.r');
%%[r, c] = find(planesDiff == max(planesDiff(:)));
%%plot(r , c, '.r');
[xx , yy] = max(max(planesDiff));
%[xx , yy] = find(planesDiff == maxVal);
plot(xx , yy , '.r');
PROBLEM CODE END
%THRESHOLD PORTION
hold off
planesDiff = 255*(planesDiff>=16);
subplot(4, 1, 4);
imagesc(planesDiff);
axis off
title('THRESHOLD');
4 个评论
Image Analyst
2018-9-23
Unfortunately it looks like you STILL forgot to attach 'planes1.bmp' and 'planes2.bmp'.
I'll check back tomorrow for the original, single images, not a composite image of 4 images.
回答(1 个)
KSSV
2018-9-22
编辑:KSSV
2018-9-22
You need not to use find to get the maximum value. max itself gives you the index and value.
[val,idx]=max(I(:));
If you want row and column use ind2sub.
1 个评论
Image Analyst
2018-9-22
max() only fives the FIRST max, not ALL of the locations. If you want all the locations where the max occurs, you'll still have to use find().
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!