Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

test: Reply
 
LinkBack Thread Tools
Old June 22nd, 2013, 10:29 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Oct 2012
Location: Queensland, Australia
Gender: Male
Posts: 7
 
Device(s): LG Optimus
Carrier: Not Provided

Thanks: 5
Thanked 0 Times in 0 Posts
Question averaging pixel values above a threshold

I have had a mental block (again).

I am after a way to average the greyscale pixel values above a set threshold. I am not interested in getting an image, and already have the conversion to greyscale (relevant tidbit of code below):

Quote:

bmp.getPixels(
pixels, 0, bmp.getWidth(), 0, 0, bmp.getWidth(), bmp.getHeight());


for(int x = 0; x < bmp.getWidth(); ++x) {
for(int y = 0; y < bmp.getHeight(); ++y) {
int index = y * bmp.getWidth() + x;
int R = (pixels[index] >> 16) & 0xff;
int G = (pixels[index] >> 8) & 0xff;
int B = pixels[index] & 0xff;


double Grey = (0.299 * R + 0.587 * G + 0.114 * B);
What I need now is how to determine the average Grey value above a set threshold. The part I am having difficulty with is counting how many pixels are left over above the threshold, and adding the values of these pixels.

irradiation is offline  
Last edited by irradiation; June 22nd, 2013 at 10:34 PM. Reason: more info added and fixed quote
Reply With Quote
sponsored links
Reply
Tags
bitmap, threshold


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 04:05 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.