My code is showing error " matrix dimension must agree".In line no -4 (2nd function:function [res_img]=Gray_trans_S_curve_uint16(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
KALYAN ACHARJYA
2018년 6월 10일
Share the main code where you call these two function, it would be helpful to get answered.
Milan Singh
2018년 6월 10일
Majid Farzaneh
2018년 6월 10일
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.
Majid Farzaneh
2018년 6월 10일
َAnother problem is that you didn't return Res value in the function 'Local_Process_uint16_mymod' You should assign output to Res variable.
Milan Singh
2018년 6월 10일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Morphological Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


