how to solve the following error in the code?

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 Kommentare

What does
size ycbcrOutImg
size y_outImg
reveal?
Poonam
Poonam am 28 Nov. 2013
Bearbeitet: Poonam am 28 Nov. 2013
y_outImg-<112x168 double>, 2D
ycbcrOutImg-<113x170x3 double> 3D
dpb
dpb am 28 Nov. 2013
Bearbeitet: dpb am 1 Dez. 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...

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Images finden Sie in Hilfe-Center und File Exchange

Produkte

Gefragt:

am 27 Nov. 2013

Bearbeitet:

dpb
am 1 Dez. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by