Borrar filtros
Borrar filtros

How to R,G and B channels of an image? These 3 separate images are at an offset

2 visualizaciones (últimos 30 días)
Given R, G and B channel of an image, at an offset, how do you align it to form an image?

Respuestas (2)

Walter Roberson
Walter Roberson el 18 de En. de 2016
Assuming 2D arrays R, G, B, and scalars Rrow_offset, Rcol_offset, Grow_offset, Gcol_offset, Brow_offset, Bcol_offset, each of which are the row or column offsets from the upper left for that color plane (that is, I do not assume that the three planes have the same offsets or that they have the same sizes)
[Rrow, Rcol] = size(R);
[Grow, Gcol] = size(G);
[Brow, Bcol] = size(B);
maxrow = max([Rrow + Rrow_offset, Grow + Grow_offset, Brow + Brow_offset]);
maxcol = max([Rcol + Rcol_offset, Gcol + Gcol_offset, Bcol + Bcol_offset]);
aligned_RGB = zeros(maxrow, maxcol, class(R)); %same datatype as R
aligned_RGB(Rrow_offset + (1:Rrow)-1, Rcol_offset + (1:Rcol)-1) = R;
aligned_RGB(Grow_offset + (1:Grow)-1, Gcol_offset + (1:Gcol)-1) = G;
aligned_RGB(Brow_offset + (1:Brow)-1, Bcol_offset + (1:Bcol)-1) = B;
  2 comentarios
Walter Roberson
Walter Roberson el 18 de En. de 2016
What exactly are the inputs? Three 2D matrices of the same size, each of which represents one color channel from the same object taken from the same location (at the same time) but for some reason the channels have been shifted relative to each other? Is there rotation? Is the match possibly not exact? Is there possibly distortion between the images? Is this an attempt at stereo image rectification except with three cameras?

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 18 de En. de 2016
Just extract the 3 color channels
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
Then call imregister() to align the green image with the red one, and again to align the blue image with the red one. imregister() was meant for this kind of thing.

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by