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

2 次查看(过去 30 天)
Given R, G and B channel of an image, at an offset, how do you align it to form an image?

回答(2 个)

Walter Roberson
Walter Roberson 2016-1-18
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 个评论
Walter Roberson
Walter Roberson 2016-1-18
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?

请先登录,再进行评论。


Image Analyst
Image Analyst 2016-1-18
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.

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by