how to solve the following error in the code?

1 view (last 30 days)
Poonam
Poonam on 27 Nov 2013
Edited: dpb on 1 Dec 2013
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 Comments
Poonam
Poonam on 28 Nov 2013
Edited: Poonam on 28 Nov 2013
y_outImg-<112x168 double>, 2D
ycbcrOutImg-<113x170x3 double> 3D
dpb
dpb on 28 Nov 2013
Edited: dpb on 1 Dec 2013
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...

Sign in to comment.

Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!