Brightness and contrast
imadjust – change brightness or contrast in Matlab by percentage.
newImage = imadjust(originalImage, [a b], [c d]);
d are between 0 and 1.
- To decrease contrast: increase a
- To increase contrast: decrease b
- To increase brightness: increase c
- To decrease brightness: decrease d
Here is full example increasing contrast by 20%:
originalImage = imread('img.tif');
%show original image
contrastImage = imadjust(originalImage, [0 0.8], [0 1]);
%show contrast image
|increases the combination of brightness and contrast of the image: image(uint8(double(originalImage(:,:,:)) * 2));
|mesh(double(cartman(:,:,3))); In this example, we are examining layer 3 = blue. Before meshing the image, we convert it to data type double.
|To view thered intensity image and a corresponding intensity color bar, we issue: image(cartman(:,:,1)), colorbar;The first colon denotes all rows, the second colon all columns, and the third index denotes the color Red.
When I attempt to cluster my integer data using KMEANS, I receive the following error
??? Error using ==> minus
Integers can only be combined with integers of the same class, or scalar doubles.
This error is the expected behavior for passing an integer data type to the KMEANS function. KMEANS and many other statistical functions are not designed to work with integer data in MATLAB 7.2 (R2006a).
The only workaround is to convert the integer data to a double data type before passing it to KMEANS. For more information, refer the following documentation page on the DOUBLE function: