how to modulate two images in which one is color image and other is matlab generated object?

2 visualizaciones (últimos 30 días)
i want to modulate color fringe pattern(i) with matlab generated peak object(Q), i have a code % object
m = 256;
n = 256;
[x,y,z] = peaks;
z = imresize(z,[m,n]);
Q = exp(1i*z*2.5); % Increase the fringes by 2.5 times
imshow(Q,[])
% color fringe pattern
f1 = 20; % No. of vertical fringes
f2 = 0; % No. of horizontal fringes
a1 = zeros(m,n);
a2 = zeros(m,n);
a3 = zeros(m,n);
for i = 1:m
for j = 1:n
a1(i,j) = exp(1i*(2*pi*(f1*j/n+f2*i/m)-2*pi/3));
a2(i,j) = exp(1i*(2*pi*(f1*j/n+f2*i/m)));
a3(i,j) = exp(1i*(2*pi*(f1*j/n+f2*i/m)+2*pi/3));
end
end
Color = zeros(m,n,3);
Color(:,:,1) = a1;
Color(:,:,2) = a2;
Color(:,:,3) = a3;
% imshow(Color,[]),impixelinfo;
% imwrite(Color,'myimage.jpg');
% i = imread('myimage.jpg');
so how to modulate i with Q ?

Respuestas (1)

Hitesh
Hitesh el 5 de Mzo. de 2025
Hi ajeet,
To modulate the color fringe pattern "Color" with the MATLAB generated object "Q", you need to perform element-wise multiplication between the two arrays. This will apply the modulation pattern "Q" to each channel of the color image. Kindly refer to the following code:
% Modulate each channel of the color image with Q
ModulatedColor = zeros(m, n, 3);
ModulatedColor(:,:,1) = Color(:,:,1) .* Q;
ModulatedColor(:,:,2) = Color(:,:,2) .* Q;
ModulatedColor(:,:,3) = Color(:,:,3) .* Q;
% Display the modulated color image
imshow(ModulatedColor, []);
impixelinfo;
  • Element-wise Multiplication: The operation Color(:,:,k) .* Q is performed for each color channel k. This multiplies each element of the color channel by the corresponding element in "Q".
  • Complex Numbers: Since "Q" and "Color" are complex arrays, the multiplication will affect both the magnitude and phase of the original color image.

Categorías

Más información sobre Image Segmentation and Analysis en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by