farbe eines bildes verändern in matlab

To change the color of an image in Matlab, you can use the imread and imwrite functions to read and write image files, and the imadjust function to adjust color values.

Here's an example code that changes the color of an input image to blue:

main.m
% Read input image
I = imread('input_image.jpg');
% Convert to double precision
I = im2double(I);
% Split channels
R = I(:,:,1);
G = I(:,:,2);
B = I(:,:,3);
% Generate blue mask
mask = ones(size(I));
mask(:,:,1) = 0;
mask(:,:,2) = 0;
% Adjust blue channel
B = imadjust(B,[],[],0.5);
% Reconstruct image
out = R.*mask(:,:,1) + G.*mask(:,:,2) + B.*mask(:,:,3);
% Write output image
imwrite(out, 'output_image.jpg');
414 chars
19 lines

In this code, we first read the input image using the imread function, and convert it to double precision using im2double. We then split the image into its RGB channels, and generate a blue mask with ones in the blue channel and zeros elsewhere.

Next, we use the imadjust function to adjust the intensity values of the blue channel. The second and third arguments of imadjust specify the output intensity range, and the fourth argument is the gamma value of the contrast adjustment.

Finally, we reconstruct the modified image and write it to a file using imwrite.

Note that you can customize this code to change the color of the image to any color you want by adjusting the values of the mask and the color channel you want to modify.

related categories

gistlibby LogSnag