Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » tif image 16 bit. autolevel
Re: tif image 16 bit. autolevel [message #32236 is a reply to message #32233] Mon, 02 May 2011 16:21 Go to previous messageGo to previous message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

I thing this is what I look for:
http://en.wikipedia.org/wiki/Histogram_equalisation
I did a variant of autolevel, but I intend to modify by wikipedia specification.
Image ImageAutolevel(const Image& img){
	uint64 histogram[256];
	for(int i=0;i<256;++i)
		histogram[i]=0;
	
	const RGBA *start = img;
	const RGBA *s = start;
	const RGBA *e = s + img.GetLength();
	while(s < e){
		histogram[(s->r+s->g+s->b)/3]++;
		s++;
	}
	int v_lower = -1;
	int v_upper = -1;
	
	for(int i=0;i<256&&(v_lower==-1||v_upper==-1);++i){
		if(v_lower==-1&&histogram[i]!=0)
			v_lower = i;
		if(v_upper==-1&&histogram[255-i]!=0)
			v_upper = 255-i;
	}
	
	// return if not sense to autolevel
	//if(v_lower==v_upper==-1)
	
	if(v_lower==-1)
		v_lower = 0;
	
	if(v_upper==-1)
		v_upper = 255;
	
	s = start;
	ImageBuffer w(img.GetSize());
	Unmultiply(w);
	RGBA *t = w;
	
	while(s < e) {
		t->r = s->r*255/v_upper;
		t->g = s->g*255/v_upper;
		t->b = s->b*255/v_upper;
		t->a = s->a;
		t++;
		s++;
	}
	Premultiply(w);
	w.SetHotSpots(img);
	return w;
}
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Printing a Layout
Next Topic: new! ANTI VIRUS FALSE POSITIVE with Upp (GUI MT FileSel)
Goto Forum:
  


Current Time: Wed May 15 00:22:23 CEST 2024

Total time taken to generate the page: 0.02850 seconds