Finding max intensity pixel in image doesnt work in code

조회 수: 9 (최근 30일)
john hancock
john hancock 2018년 9월 22일
편집: Stephen23 2018년 9월 23일
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
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
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
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!

Translated by