0

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) 
Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
E. Zahra
  • 87
  • 1
  • 16
  • @CrisLuengo im changing image brightness for indexed image in matlabfor that i created m a 3*256 ones matrix then i multiply with a number then i add m to x (the map for my image) my question now how to return one if result bigger than one – E. Zahra Nov 02 '19 at 16:01

1 Answers1

3

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)
Cris Luengo
  • 55,762
  • 10
  • 62
  • 120