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 Ansicht (letzte 30 Tage)
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 Kommentare
Majid Farzaneh
Majid Farzaneh am 10 Jun. 2018
َAnother problem is that you didn't return Res value in the function 'Local_Process_uint16_mymod' You should assign output to Res variable.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Majid Farzaneh
Majid Farzaneh am 10 Jun. 2018
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 Kommentare
Majid Farzaneh
Majid Farzaneh am 11 Jun. 2018
By the way you can also use histeq() and adapthisteq() functions for contrast enhancement. note that the input must be 2-D.
Good luck!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by