How can I perform a comparison function (of surrounding pixels) on a DEM using a starting pixel?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (3)
Wolfgang Schwanghart
el 19 de Jul. de 2012
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
el 19 de Jul. de 2012
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);
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!