MATLAB: Adjust brightness and contrast

brightnesscontrastImage Processing Toolbox

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

Best Answer

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
If you have the Image Processing Toolbox take a look at the Image Viewer App
Hope that helps get you started!