how to match both the side?

1 次查看(过去 30 天)
Poonam
Poonam 2013-11-29
编辑: Poonam 2013-11-30
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

回答(1 个)

Wayne King
Wayne King 2013-11-29
编辑:Wayne King 2013-11-29
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 个评论
Image Analyst
Image Analyst 2013-11-29
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 2013-11-30
编辑:Poonam 2013-11-30
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by