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

조회 수: 1 (최근 30일)
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
Majid Farzaneh
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
Milan Singh 2018년 6월 10일
@Majid Farzaneh I have send another file. Please tell me what input you are taikng in command window.

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

채택된 답변

Majid Farzaneh
Majid Farzaneh 2018년 6월 10일
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
Majid Farzaneh
Majid Farzaneh 2018년 6월 11일
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개)

Community Treasure Hunt

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

Start Hunting!

Translated by