Finding areas of an image?
조회 수: 1 (최근 30일)
이전 댓글 표시
So I have the following images


How can I calculate the number of elements (pixels in each image) that represents the sea area assuming sea area in 1957 is 68km^2?
Guidelines:
(a) initialize the black and white images with zeros.
(b) use logical operation to replace all matrix elements that is <=180 to 1, the rest of the elements remains as 0.
(c) use matrix addressing to exclude the text at the bottom of the image in your calculation
(d) sum up the ones in the black and white image as the sea area.
finally, Write the year, estimated sea area by pixel and estimated sea area by km2 into a text file named AralSeaAreaData.txt.
Thank you so much
댓글 수: 0
답변 (1개)
Image Analyst
2014년 5월 17일
(a) is unnecessary if you're going to do (b), but you should use false() (a logical) though you can use zeros() like instructed (which will give a double), it's just that when you do step (b) it will change the data type from double to logical so you might as well just start with logical in the first place.
To threshold
binaryImage = grayImage <= 180
That is a binary (logical image) which should be fine. It will show as 1 and 0 even though it's really true and false (logical) rather than 0 and 1 (int32).
To get a sub-image for (c):
subimage = binaryImage(row1:row2, column1:column2);
You might want to use this:
axis on;
For (d), use the sum function like it says. You might have to use it twice sum(sum(theMatrix)) or turn the matrix into s column vector first sum(theMatrix(:)).
You may also find imfill(binaryImage, 'holes') useful.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!