Adjust brightness and contrast
29 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
jchris14
el 30 de Jul. de 2014
Comentada: aswathy pavithran
el 29 de Oct. de 2019
Hello,
How do I write a command in a script so that as soon as i run it and enter imread('image'), this command will automatically set the brightness and contrast to a predetermined level. The images im mainly focusing on are grayscale images.
thanks
0 comentarios
Respuesta aceptada
Ben11
el 30 de Jul. de 2014
Editada: Ben11
el 30 de Jul. de 2014
You are probably looking for the imadjust command. As you can see in the documentation the basic syntax for imadjust is
OutputImage = imadjust(InputImage,[low_in; high_in],[low_out; high_out])
where low_in,high_in,low_out and high_out are between 0 and 1. Hence you could assign predetermined values to those and run imadjust on your images. There also a gamma parameter which you can add in you call to imadjust. This factor is used to enhance in a non-linear fashion low or high intensity signals. More info here
Hope that helps get you started!
2 comentarios
Ben11
el 30 de Jul. de 2014
In general you will use [] for the low_out/high_out parameters (based on my very modest experience but of course you can play around to see how it changes the output image), since you want the output image pixels to span the entire range of possible values, i.e. from "relative" 0 to 1, so normalized as you mentioned. By default Matlab makes the higher and lower 1% of the pixels saturated if you simply call imadjust(Image).
As for the low_in/high_in, this is what you want to play with since the pixel distribution in the output image is calculated from the range defined by low_in and high_in. If you need to automatically select a range, you could obtain the pixel histogram distribution (e.g. imhist) and write some code to select the appropriate range based on the distribution. One important thing being that all your input images must be of the same class (eg. uint8,uint16,etc.).
I hope my explanations were clearer than they are in my head :)
Más respuestas (2)
Image Analyst
el 30 de Jul. de 2014
If the "predetermined level" is just 0 to 255 so that it can display on a video monitor with the maximum possible dynamic range, just do
imshow(grayImage, []);
That will scale the min (whatever that is) to 0 and the max (whatever that happens to be) to 255. If you want specific gray levels other than 0-255, use imadjust() like Ben11 said.
3 comentarios
Image Analyst
el 30 de Jul. de 2014
Of course not. If you have A and B, you just do
B = A;
If A is a completely different image and you want to match their histograms, you use can do
C = imhistmatch(B, A);
Rodrigo Souza
el 28 de En. de 2019
Hi all,
I have put together three scripts/functions for calculating (mean and SD), matching or normalizing luminance of colored images (using HSV and CIE Lab color spaces).
They may be specially useful for pupillometry measures of infant research.
The scripts and their descriptions are available at my OSF page: https://osf.io/auzjy/
Hope it helps.
0 comentarios
Ver también
Categorías
Más información sobre Image Preview and Device Configuration en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!