How can I perform a comparison function (of surrounding pixels) on a DEM using a starting pixel?
조회 수: 1 (최근 30일)
이전 댓글 표시
I would like to write a function that would take as input, a starting pixel in a Digital Elevation Model raster, that would identify all pixels connected with this pixel that have the same (or lower) elevation. I'm not sure if I should use a simple region-growing algorithm for this. Thanks!
댓글 수: 0
답변 (3개)
Wolfgang Schwanghart
2012년 7월 19일
Hi,
you might be interested in using the function ixneighbors available on the FEX which might make life a little easier for your task.
Say, you are interested in the pixel with the linear index ix you can proceed as follows
[ic,icd] = ixneighbors(dem,ix);
I = dem(icd)<=dem(ic);
ixn = icd(I);
In addition, you might be interested in TopoToolbox that has various functions for terrain analysis in Matlab.
Regards, W.
Image Analyst
2012년 7월 19일
If you have the Image Processing Toolbox you could do it in 4 lines without writing your own region growing code by using morphological reconstruction. Here's some untested code just off the top of my head. You could just threshold your image
binaryImage = yourImage <= pixelValue;
Then use imreconstruct to grab only that one region connected to your specified pixel.
% Create a marker image.
markerImage = false(size(yourImage)); % Initialize to all false.
markerImage(row, column) = true; % Set the pixel that you're interested in.
% Extract the connected pixels.
connectedBlob = imreconstruct(binaryImage, markerImage, 8);
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!