|
|
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » tif image 16 bit. autolevel
|
|
Re: tif image 16 bit. autolevel [message #32178 is a reply to message #32173] |
Fri, 29 April 2011 11:02 |
|
tojocky wrote on Fri, 29 April 2011 08:54 | Hello,
I have a trouble with load 16bit tiff image and set color/contrast auto-level.
Is possible in U++?
Thank you in advance!
|
Hi Ion,
Unfortunately, U++ doesn't support 16 bit tiffs at the moment, and even libtiff support is quite limited. Have a look at this thread about the same topic, there are some links to sites suggesting how to possibly overcome these limitations...
Best regards,
Honza
|
|
|
Re: tif image 16 bit. autolevel [message #32182 is a reply to message #32175] |
Fri, 29 April 2011 11:28 |
|
koldo wrote on Fri, 29 April 2011 11:12 | Hello Ion
Is it a 16 bits per color image?
What do you mean with set color/contrast auto-level?
|
In Photoshop Exists possibility to change color/contrast level.
Thank you for quick response!
|
|
|
Re: tif image 16 bit. autolevel [message #32183 is a reply to message #32178] |
Fri, 29 April 2011 11:35 |
|
dolik.rce wrote on Fri, 29 April 2011 12:02 |
tojocky wrote on Fri, 29 April 2011 08:54 | Hello,
I have a trouble with load 16bit tiff image and set color/contrast auto-level.
Is possible in U++?
Thank you in advance!
|
Hi Ion,
Unfortunately, U++ doesn't support 16 bit tiffs at the moment, and even libtiff support is quite limited. Have a look at this thread about the same topic, there are some links to sites suggesting how to possibly overcome these limitations...
Best regards,
Honza
|
Thank you for hint.
I tried to open the tif image in U++. it opened OK, but on I tried to change contrast with the method:
Image Contrast(const Image& img, int amount)
but the contrast was not so good.
Any hint are welcome!
Thank you for quick response!
|
|
|
|
|
|
Re: tif image 16 bit. autolevel [message #32202 is a reply to message #32195] |
Sat, 30 April 2011 18:07 |
|
koldo wrote on Sat, 30 April 2011 10:33 | Hello Ion
In summary you can open the image right and set it in an Image. This is very good .
About the algorithm I agree with Mirek. I have searched about Photoshop algorithm unsuccessfully, but it seems they change the contrast by spreading the color histogram by all the range. There is more than one way to do it.
Please send here a sample of an image before and after that effect and we can try to give you the function.
|
Thank you Koldo for help.
I will try to find a solution too!
I have attached a simple image in tif 16bits before and after autolevel.
|
|
|
|
|
|
|
|
Re: tif image 16 bit. autolevel [message #32232 is a reply to message #32229] |
Mon, 02 May 2011 12:03 |
|
OK, Now I'm able to print the histogram!
before autolevel:
and after autolevel:
and the algorithm:
Vector<XY> hist_data;
for(int i=0;i<256;++i)
hist_data << XY(i, 0);
const RGBA *s = ~img;
const RGBA *e = s + img.GetLength();
while(s < e) {
v_curr_value = (s->r+s->g+s->b)/3;
hist_data[v_curr_value].y++;
if(hist_data[v_curr_value].y>v_max_y)
v_max_y = hist_data[v_curr_value].y;
s++;
}
The easy way remain how to compute the autolevel algorithm in base of histogram!
|
|
|
Re: tif image 16 bit. autolevel [message #32233 is a reply to message #32232] |
Mon, 02 May 2011 14:02 |
|
koldo
Messages: 3394 Registered: August 2008
|
Senior Veteran |
|
|
Hello Ion
In your case to pass from one histogram to the other is as easy as multiplying any pixel by a factor.
In a more complex scenario you should have to set a window of your histogram and determine which function to apply, like:
New color = F(Old color)
Remember to use function int Grayscale(const Color& c). The conversion to gray is more adequate .
PD. The second histogram strange zeros seem to indicate that there is a problem in the conversion program.
Best regards
Iñaki
[Updated on: Mon, 02 May 2011 14:04] Report message to a moderator
|
|
|
Re: tif image 16 bit. autolevel [message #32236 is a reply to message #32233] |
Mon, 02 May 2011 16:21 |
|
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;
}
|
|
|
|
Re: tif image 16 bit. autolevel [message #32275 is a reply to message #32237] |
Thu, 05 May 2011 20:10 |
|
koldo wrote on Mon, 02 May 2011 18:37 | Hello Ion
Your code is right, although consider this fragment:
It is better to convert your original image from RGB to HSV, apply the algorithm to the Luminance component and convert the result to RGB.
In U++ we have the functions RGBtoHSV() and HSVtoRGB().
|
Thank you Koldo! I will!
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 05:14:10 CEST 2024
Total time taken to generate the page: 0.03314 seconds
|
|
|