beyer matrix
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have this code...which separates R G and B colors from a beyer image but when i try to display the three images i m getting black images is something missing in the code?
clc; I=imread('b2.bmp'); imshow(I); I=double(I); [M,N] = size(I);
red_mask = repmat([1 0; 0 0], M/2, N/2); green_mask = repmat([0 1; 1 0], M/2, N/2); blue_mask = repmat([0 0; 0 1], M/2, N/2);
R=I.*red_mask; G=I.*green_mask; B=I.*blue_mask;
Risposte (2)
Sean de Wolski
il 21 Giu 2011
Try
imshow(R,[]);
You may just not be looking at the full range of values.
ADDENDUM per comment I'm not sure what you're trying to do (what makes a beyer image special?). If you're trying to mask the channels then your mask (for a typical rgb image) is wrong.
R = bsxfun(@times,reshape([1 0 0],[1 1 3]),I);
G = bsxfun(@times,reshape([0 1 0],[1 1 3]),I);
B = bsxfun(@times,reshape([0 0 1],[1 1 3]),I);
So that you're zeroing out the two channels (slices) that you don't want.
3 Commenti
Walter Roberson
il 21 Giu 2011
beyer images have interleaved color channels, Sean -- but it isn't a straight forward R,G,B interleave: some channels occur more frequently than others.
Eric
il 21 Giu 2011
I don't see anything wrong with your code, but I do wonder about your statement that you are "getting black images" with R, G, and B. Have you inspected the values of these arrays to know that they are zero everywhere, or are you looking at a visualization? If it's the latter, you might try imagesc() or the like.
You might also try something like:
R = I(1:2:end,1:2:end);
G1 = I(1:2:end,2:2:end);
G2 = I(2:2:end,1:2:end);
B = I(2:2:end,2:2:end);
G = (G1+G2)/2;
to index into I directly. Then R should be the actual red image (without interstitial zeros), and likewise for G and B. The way your code works R, G, and B are the same size as the original image. 75% of the values in R and B are zero and 50% of the values in G are zero.
Good luck, Eric
2 Commenti
Eric
il 23 Giu 2011
Let me give an example:
G1 = I(1:2:end,2:2:end)
extracts the elements in rows 1,3,5,...,end and columns 2,4,6,...,end (where end denotes the last row or column, which is hopefully divisible by 2 in this case).
I tried to match my code to the 2x2 arrays in the repmat() functions in your original question. It looks like the Bayer matrix is of the form
R G R G
G B G B
R G R G
G B G B
So that's why I had R start at (1,1), G start at either (1,2) or (2,1), and B start at (2,2).
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!