3

enter image description hereenter image description here

I want to mark trees present in an image. I tried many color-based segmentation methods like RGB Vector space & HSI Color Space, Lab* color space, Watershed segmentation,NDVI methods, but most of the tree areas are missing.

Does anybody know more color detection (or) segmentation procedures..?

I need to develop an algorithm in MATLAB only..

ravi raja
  • 130
  • 2
  • 11
  • It would be useful if you would show us a couple of your images, to see what you're talking about. – carlosdc Dec 10 '13 at 04:37
  • @carlosdc thq for suggestion i added two images – ravi raja Dec 10 '13 at 04:41
  • You may find some useful tips in the answers to this related question: [How can I convert an RGB image to grayscale but keep one color?](http://stackoverflow.com/q/4063965/52738) – gnovice Dec 10 '13 at 04:42

1 Answers1

4

A basic way to extract trees from remotely sensed data such as satellite or aerial imagery is to calculate the Normalized Difference Vegetation Index (NDVI) followed by thresholding the NDVI.

To illustrate, consider the following 4-band color infrared image (Warning 160MB download). The NDVI provides a means to express the intensity of live green vegetation within the range of -1:1. Often these values are stretched (as in the attached script) to fill the entire range of the image bit depth (e.g. 0-255). Once NDVI is calculated, you can threshold the image by essentially saying, "Keep only the pixel values > X". The output is a binary image, which you can use to analyze metrics such as canopy cover per unit area.

enter image description here

file = 'D:\path\to\doi1m2011_41111h4nw_usda.tif';
[I R] = geotiffread(file);
outputdir = 'D:\output\'

%% Calculate NDVI
NIR = im2single(I(:,:,4));
red = im2single(I(:,:,1));

ndvi = (NIR - red) ./ (NIR + red);
double(ndvi);
imshow(ndvi,'DisplayRange',[-1 1]);

%% Stretch to 0-255
ndvi = floor((ndvi + 1) * 128); % [-1 1] -> [0 256]
ndvi(ndvi < 0) = 0;             
ndvi(ndvi > 255) = 255;         
ndvi = uint8(ndvi);             

%% Threshold the NDVI
threshold = 100  % You may need to experiment with this value
i = (ndvi > threshold);
imshow(i)

%% Write output to disk
tiffdata = geotiffinfo(file);
outfilename = [outputdir 'threshold_image' '.tif'];  
geotiffwrite(outfilename, i, R, 'GeoKeyDirectoryTag', tiffdata.GeoTIFFTags.GeoKeyDirectoryTag)
Borealis
  • 8,044
  • 17
  • 64
  • 112