Reputation: 165
I am changing the image brightness for an indexed image in MATLAB. For that I created m
, a 3x256 ones matrix, then I multiply it with a number, then I add m
to x
(the map for my image). My question now how to return one if the result is bigger than one.
[im3,x]=imread('corn.tif');
m=ones(256,3)
m=m.*50
[im33 c]=deal(im3,x+m)
Upvotes: 0
Views: 333
Reputation: 60474
Setting values in the array x
larger than the value a
to a
is variously called clamping, clipping or saturating. The simplest method is using min
:
x = min(x,a);
For example, given your color map x
:
[im3,x] = imread('corn.tif');
subplot(1,2,1)
imshow(im3,x)
x = x + 0.2;
x = min(x,1);
subplot(1,2,2)
imshow(im3,x)
Upvotes: 3