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