# Pixel wise NDVI calculation in GEE

I have a collection of Landsat images filtered over forest regions of India over a time interval of 6 years(2013 - 2018). I have again filtered this collection such that I have one image per 4 months, that is I have filtered on a quarterly basis so that I will have 3 images per year.

Now, for a particular point, there will be 18 pixels representing it over 6 years. I have to find, out of these 18 pixels, how many satisfy the condition - NDVI < 0.25. Suppose, 10 pixels satisfy this condition, then in my output image, the pixel representing that particular point should have its value = 10. Like this I have to do for all the points in my selected region.

I have no idea as to how to do this pixel wise computation. Can somebody help me on this?

In my code, I have done till filtering quarterly wise.

``````// FILTERING OUT FOREST COVER IN INDIA

var treeCanopyCover = hansen.clip(india).select('treecover2000');
var greater25 = treeCanopyCover.gte(25);

// NDVI FUNCTION

var ndvi = image.normalizedDifference(['B5', 'B4']).rename('NDVI');
}

// FILTERING THE COLLECTION

var startDate = ee.Date('2013-01-01');
var endDate = ee.Date('2019-06-30');
var filtered = l8.filterBounds(india)
.filterDate(startDate, endDate)

var x = image.updateMask(greater25);      // filtering over forest regions
return x;
});

// FILTERING QUARTERLY WISE

var map_m = function(y)
{
var months = [1, 5, 9];
var filtered_col = months.map(function(m)
{
var start = ee.Date.fromYMD(y, m, 1)

return filt.set('year', y)
.set('month', m)
.set('system:time_start',ee.Date.fromYMD(y,m,1)) ;
});
return filtered_col;
};

var years = ee.List.sequence(2013, 2019);
var quarterlyimages = years.map(map_m).flatten();
var z = ee.ImageCollection(quarterlyimages);
``````

I think `count` method of `ImageCollection` could help with what you're doing.

Assume `col` is the `ImageCollection` that you want to deal with. Every image in this `col` has `NDVI` band that holds NDVI value. The code below will result in an image called `NDVI_count` in which value of every pixel represents the number of pixels at the corresponding location in `col` that have NDVI < 0.25.

``````var NDVI_count = col.select('NDVI')
The `map` function in the above code just does one thing: mask out any pixels that have NDVI >= 0.25. The `count` method will count the number of valid pixels (i.e. not-masked pixel) throughout the collection at each specific location.
• @ReemaMathew, you can use `ui.Chart.image.histogram` to create such chart. To specify which chart type, `setChartType` can be used after creating the chart. – Kevin Jul 9 at 11:25