My code is showing error " matrix dimension must agree".In line no -4 (2nd function:function [res_img]=​Gray_trans​_S_curve_u​int16(xyz)​)-nrm_val= (xyz)- mn1;.output of the 1st function will be used in 2nd function.1st fn :function Res=Local_Process_uin

function Res=Local_Process_uint16_mymod(inputImage,nblockrow,nblockcolumn) [m,n] = size(inputImage); dcol = fix(n/nblockcolumn); drow = fix(m/nblockrow); for index = 1:nblockrow* nblockcolumn
[r,c] = ind2sub([nblockrow,nblockcolumn],indexa );
if (r==nblockrow && c~=nblockcolumn)
subimage = inputImage((r-1)*drow+1:r*drow+rem(m,nblockrow), (c-1)*dcol+1:c*dcol,:);
elseif (r~=nblockrow && c==nblockcolumn)
subimage = inputImage((r-1)*drow+1:r*drow, (c-1)*dcol+1:c*dcol+rem(n,nblockcolumn),:);
elseif (r==nblockrow && c==nblockcolumn)
subimage = inputImage((r-1)*drow+1:r*drow+rem(m,nblockrow), (c-1)*dcol+1:c*dcol+rem(n,nblockcolumn),:);
else
subimage = inputImage((r-1)*drow+1:r*drow, (c-1)*dcol+1:c*dcol,:);
end;
subimage;
test_th=Gray_trans_S_curve_uint16(double(subimage));
Box_new{r,c}=test_th;
subimage=[];
end
Res=cell2mat(Box_new); % figure,imshow(Res,[]); % 2nd function
function [res_img]=Gray_trans_S_curve_uint16(xyz) mn1 = min(xyz(:)); mx1=max(xyz(:)); mxl nrm_val= (xyz)- mn1; diff = (mx1-mn1); res=[]; res_img=[]; xyz_norm = nrm_val ./ diff;
[m,n]=size(xyz_norm);
for i=1:m for j=1:n res(i,j)=(0.9642)+((8.594*10^-4-0.9642)/(1+exp((xyz_norm(i,j)-0.4969)/0.07598))); end; end;
res_img=uint16(((mx1-mn1)*res)+mn1);
%endThe attached file contains contrast enhancement code. function Res=Local_Process_uint16_mymod(inputImage,nblockrow,nblockcolumn) will take input as image and size of blocks of subimage.Output of the image will be sed in another function name:function [res_img]=Gray_trans_S_curve_uint16(xyz). but it is showing error. example:function Res=Local_Process_uint16_mymod('mrimage.bmp',40,40) objective: The function function Res=Local_Process_uint16_mymod(inputImage,nblockrow,nblockcolumn) will take input image and divide the image into non overlapping blocks. after that each block will be given as input to the function [res_img]=Gray_trans_S_curve_uint16(xyz) to perform contrast enhancement. but in line no 4 it is showing error Marix dimenson must agree.%

댓글 수: 5

Share the main code where you call these two function, it would be helpful to get answered.
Hi, do you have a file 'mxl.m'?
I have an error in Gray_trans_S_curve_uint16.m- Line5. mxl is not defined. By removing line5, it works. But I don't know it works correct or not.
َAnother problem is that you didn't return Res value in the function 'Local_Process_uint16_mymod' You should assign output to Res variable.
@Majid Farzaneh I have send another file. Please tell me what input you are taikng in command window.

댓글을 달려면 로그인하십시오.

 채택된 답변

If your input is an image it's incorrect to use it like this:
Res=Local_Process_uint16_mymod('mrimage.bmp',40,40)
'mrimage.bmp' is a string not an image. You should first read the image:
I=imread('mrimage.bmp');
Res=Local_Process_uint16_mymod(I,40,40)

댓글 수: 6

Sir,this time i amgetting different error Error in Local_Process_uint16_mymod (line 18) subimage = inputImage((r-1)*drow+1:r*drow, (c-1)*dcol+1:c*dcol,:);
I don't have any error by this:
Probably your image is the problem. Can you send me 327.bmp or mriimage.bmp??
Hi again. The problem is your input image size. Your input has 3 dimensions. But your function works for 2-D image. Before using the function use rgb2gray or mat2gray function for your original image:
I=imread('327.bmp');
Ig=rgb2gray(I);
figure, imshow(Ig), title('original image');
Res=Local_Process_uint16_mymod(Ig,40,40);
figure, imshow(mat2gray(Res)), title('Enhanced image');
By the way you can also use histeq() and adapthisteq() functions for contrast enhancement. note that the input must be 2-D.
Good luck!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2018년 6월 10일

댓글:

2018년 6월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by