how to solve the following error in the code?
2 次查看(过去 30 天)
显示 更早的评论
clc;
close all;
% clear all;
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;
ycbcrOutImg(:,:,2) = cb_inImg;
ycbcrOutImg(:,:,3) = cr_inImg;
*
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;* *
3 个评论
dpb
2013-11-28
编辑:dpb
2013-12-1
So, there's your problem...the two aren't commensurate in size. Now that you see that one is a row longer and two columns wider than the other, do whatever it is that you needs must to correct it. Throw away a row and two columns or pad the smaller or whatever your application should do...
回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!