MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

# How can i improve marker controlled watershed segmentation algorithm for tree crown delineation using satellite image.I want neat boundaries for tree crowns.plz help me

http://www.rmrkz.com/Gallery.html

``` clc
clear all
close all
imshow(rgb)
I = rgb2gray(rgb);
imshow(I)
```hy = fspecial('sobel');
hx = hy';
Iy = imfilter(double(I), hy, 'replicate');
Ix = imfilter(double(I), hx, 'replicate');
```
```L = watershed(gradmag);
Lrgb = label2rgb(L);
%figure, imshow(Lrgb), title('Watershed transform of gradient magnitude (Lrgb)')
```
```se = strel('disk',3);
Io = imopen(I, se);
figure, imshow(Io), title('Opening (Io)')
```
```Ie = imerode(I, se);
Iobr = imreconstruct(Ie, I);
figure, imshow(Iobr), title('Opening-by-reconstruction (Iobr)')
Ioc = imclose(Io, se);
figure, imshow(Ioc), title('Opening-closing (Ioc)')
Iobrd = imdilate(Iobr, se);
Iobrcbr = imreconstruct(imcomplement(Iobrd), imcomplement(Iobr));
Iobrcbr = imcomplement(Iobrcbr);
figure, imshow(Iobrcbr), title('Opening-closing by reconstruction (Iobrcbr)')
fgm = imregionalmax(Iobrcbr);
%figure, imshow(fgm), title('Regional maxima of opening-closing by reconstruction (fgm)')
I2 = I;
I2(fgm) = 255;
figure, imshow(I2), title('Regional maxima superimposed on original image (I2)')
se2 = strel(ones(5,5));
fgm2 = imclose(fgm, se2);
fgm3 = imerode(fgm2, se2);
```
```fgm4 = bwareaopen(fgm3, 20);
I3 = I;
I3(fgm4) = 255;
figure, imshow(I3)
title('Modified regional maxima superimposed on original image (fgm4)')
bw = im2bw(Iobrcbr, graythresh(Iobrcbr));
%figure, imshow(bw), title('Thresholded opening-closing by reconstruction (bw)')
D = bwdist(bw,'euclidean');
DL = watershed(D);
bgm = DL == 0;
%figure, imshow(bgm), title('Watershed ridge lines (bgm)')
I4 = I;
I4(imdilate(L == 0, ones(3, 3)) | bgm | fgm4) = 255;
figure, imshow(I4)
title('Markers and object boundaries superimposed on original image (I4)')
Lrgb = label2rgb(L, 'jet', 'w', 'shuffle');
figure, imshow(Lrgb)
title('Colored watershed label matrix (Lrgb)')
figure, imshow(I), hold on
himage = imshow(Lrgb);
title('Lrgb superimposed transparently on original image')
```

[Merged information from duplicate question]

I hav tried to implement marker controlled watershed segmentation algorithm but the trees are not delineated correctly.plz help me with code.i hav to count no.of trees in a setellite image.is there any other alg to do this

Image Analyst on 6 Jul 2012

Walter Roberson on 9 Jul 2012

That google.co.in image is the Figure that the paper uses to illustrate that the paper's algorithm does not work well in some cases. Getting an algorithm that works better would be a topic for a sustained research project on your part, not something you can expect that one of the volunteers will be able to suggest in five or ten minutes thinking.

## Products

No products are associated with this question.

Answer by Image Analyst on 7 Jul 2012

I'd say that it is impossible for that photo. I can't even tell. It's just one big solid mass of green. You can't tell because you have tall trees and short trees and their branches overlap and penetrate neighboring trees, plus there's probably lots of underbrush in there as well. Any segmentation you did get probably wouldn't be very accurate. Why do you want the individual trees anyway?

There may be some hope if the trees are well separated or you have different species with different spectra. See the VisonBib: http://iris.usc.edu/Vision-Notes/bibliography/contentscartog.html#Cartography,%20Aerial%20Images,%20Remote%20Sensing,%20Buildings,%20Roads,%20Terrain,%20ATR

See these sections:

```22.5.4 Trees, Individual Trees, Tree Crowns
22.5.4.1 Trees, Forest, Stem Volume, Biomass Measurements
22.5.4.2 Forest Extraction, Forest Analysis
```