How to sum binary sub pixels from 150x150 pixels?

조회 수: 3 (최근 30일)
Kh. Islam
Kh. Islam 2016년 8월 4일
댓글: Kh. Islam 2016년 10월 14일
I have a binary image 150x150 pixels, I would like to divided into 4 part so 1st part pixel ration (X:Y) will be (1:75, 1:75) and 2nd part will be (1:75, 76:end) and 3rd will be (76:end, 1:75) and 4th will be (76:end, 76:end). Now I would like to calculate sum of 1st, 2nd, 3rd and 4th divided part.

채택된 답변

Image Analyst
Image Analyst 2016년 8월 5일
Another way:
upperLeftSum = sum(sum(binaryImage(1:75, 1:75)))
upperRightSum = sum(sum(binaryImage(1:75, 76:end)))
lowerLeftSum = sum(sum(binaryImage(76:end, 1:75)))
lowerRightSum = sum(sum(binaryImage(76:end, 76:end)))
  댓글 수: 1
Kh. Islam
Kh. Islam 2016년 10월 14일
Thank you very much, it is really appreciated.

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

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 8월 4일
편집: Azzi Abdelmalek 2016년 8월 4일
A=randi([0 1],150) % Example
b=mat2cell(A,75*ones(2,1),75*ones(2,1))
out=cellfun(@(x) sum(x(:)),b)
If you have Image Processing toolbox
out=blockproc(A,[75,75],@(x) sum(x.data(:)))
  댓글 수: 1
Kh. Islam
Kh. Islam 2016년 8월 4일
Thank you for your Answer it is really it is really appreciated.

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

Community Treasure Hunt

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

Start Hunting!

Translated by