Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
Given R, G and B channel of an image, at an offset, how do you align it to form an image?

Antworten (2)

Walter Roberson
Walter Roberson am 18 Jan. 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 Kommentare
Walter Roberson
Walter Roberson am 18 Jan. 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?

Melden Sie sich an, um zu kommentieren.


Image Analyst
Image Analyst am 18 Jan. 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.

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by