how to match both the side?

1 visualización (últimos 30 días)
Poonam
Poonam el 29 de Nov. de 2013
Editada: Poonam el 30 de Nov. de 2013
Sir, If LHS is 3D image and RHS is 2D then how to match both the side
eg.
outimg(:,:,1)=out1img
how to convert the RHS(2D-image) to LHS (3D)
* *outimg* * is rgb image

Respuestas (1)

Wayne King
Wayne King el 29 de Nov. de 2013
Editada: Wayne King el 29 de Nov. de 2013
If it's a simple matter of assigning matrices, then your syntax works.
outimg = zeros(256,256,3);
out1img = ones(256,256);
outimg(:,:,1) = out1img;
or
out2img = randn(256,256);
out3img = randn(256,256);
outimg = cat(3,out1img,out2img,out3img);
But if you are trying to convert a grayscale image into RGB, there's more to it than simply copying images into the 3 pages of a new matrix (unless you've done the work already). You may want to look at this answer:
  3 comentarios
Image Analyst
Image Analyst el 29 de Nov. de 2013
Wayne, since he works for the Mathworks, may have the Crystal Ball Toolbox, but I don't , so you'd need to attach your code for me to see what you're doing wrong.
Poonam
Poonam el 30 de Nov. de 2013
Editada: Poonam el 30 de Nov. de 2013
inImg = imread('C:\Users\Poonam\Desktop\MATLAB\R2008a\bin\matlabimage\lotus.jpg');
figure;imshow(inImg);title('Input Image');
s_inImg = size(inImg);
outImg = zeros(s_inImg);
ycbcrOutImg = zeros(s_inImg);
%DCT Parameters
blkSize = 8;
ycbcrInImg = rgb2ycbcr(inImg);
y_inImg = ycbcrInImg(:,:,1);
cb_inImg = ycbcrInImg(:,:,2);
cr_inImg = ycbcrInImg(:,:,3);
I_max = max(max(y_inImg));
%Block-wise Splitting
y_blocks = Mat_dec(y_inImg, blkSize);
s = size(y_blocks);
dctBlks = zeros(s);
for i = 1 : s(3)
for j = 1 : s(4)
localBlk = y_blocks(:,:,i,j);
localdctBlk = dct2(localBlk);
localdctBlk = localdctBlk ./ 8;
orig_dc = localdctBlk(1,1);
%Adjustment of Local Background Illumination
x = localdctBlk(1,1) / double(I_max);
mapped_dc = x * (2 - x) * double(I_max);
%Preservation of Local Contrast
k = mapped_dc / orig_dc;
localdctBlk(1,1) = k * localdctBlk(1,1);
dctBlks(:,:,i,j) = localdctBlk;
end
end
dctImg = merge_blocks(dctBlks);
dctImg = dctImg .* 8;
*y_outImg = blkproc(dctImg, [8 8], 'idct2(x)');
ycbcrOutImg(:,:,1) = y_outImg;//Error
ycbcrOutImg(:,:,2) = cb_inImg;//error
ycbcrOutImg(:,:,3) = cr_inImg;//error 2D assign to 3D
*
ycbcrOutImg = uint8(ycbcrOutImg);
rgbOutImg = ycbcr2rgb(ycbcrOutImg);
figure;imshow(rgbOutImg);title('DC Adjustment');
*??? Subscripted assignment dimension mismatch.
Error in ==> colordct at 57
ycbcrOutImg(:,:,1) = y_outImg;* *
This is what i m getting

Iniciar sesión para comentar.

Categorías

Más información sobre Images 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