Maximising Pixels within Certain area of Matrix

조회 수: 1 (최근 30일)
Harry Andrews
Harry Andrews 2018년 7월 13일
댓글: Harry Andrews 2018년 7월 13일
Hi Everyone,
I'd like to loop through a matrix (128x128) and find the area (Lets say 5x5 Pixels) with the highest pixel values.
What is the best way to do this?
Thanks!
  댓글 수: 2
Guillaume
Guillaume 2018년 7월 13일
편집: Guillaume 2018년 7월 13일
What is the definition of an area with the highest pixel values? One whose sum of pixel values is the greatest? One whose maximum is the greatest? Something else?
Harry Andrews
Harry Andrews 2018년 7월 13일
편집: Harry Andrews 2018년 7월 13일
One whose sum of pixel values is the greatest please :)
Thank you for helping!

댓글을 달려면 로그인하십시오.

채택된 답변

Guillaume
Guillaume 2018년 7월 13일
편집: Guillaume 2018년 7월 13일
One whose sum of pixel values is the greatest
Convolve your matrix with an array of 1 the same size as the area. The location of the maximum of the convolution is the centre of the area with the highest sum:
areasum = conv2(yourmatrix, ones(5)), 'same');
[~, idx] = max(areasum);
[centrerow, centrecol] = ind2sub(size(yourmatrix), idx)

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by