本文介绍了如何使用MATLAB从图像中检测树?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想标记图像中存在的树。我尝试了许多基于颜色的分割方法,如RGB Vector space& HSI彩色空间,L a b *颜色空间,流域分割,NDVI方法,但大多数树状区域都丢失。

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..?

我只需要在MATLAB中开发一个算法。

I need to develop an algorithm in MATLAB only..

推荐答案

从卫星或航空图像等遥感数据中提取树木的基本方法是计算归一化差异植被指数(NDVI),然后对NDVI进行阈值处理。

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.

说明了以下提供了一种表达活性绿色植被强度在-1: 1。通常,这些值被拉伸(如附加脚本中)以填充图像位深度的整个范围(例如0-255)。一旦NDVI计算,您可以通过基本上说只保留像素值> X来阈值图像。输出是一个二进制图像,您可以使用它来分析每单位面积的覆盖率等指标。

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.

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)

这篇关于如何使用MATLAB从图像中检测树?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 05:44