Question

I am using blockproc for splitting the image into 10x10 overlapping image blocks and I want to extract features of these blocks, but Matlab is giving errors. The code for the task is pasted here. The Matlab error is

 Error in ==> blockproc at 214
output_block = userfunDispatcher(fun,input_struct,trim_border);

 Error in ==> Main at 57
B1 = blockproc(g,[4 4],fun,'BorderSize',[3 3]); %[M + 2*V, N + 2*H] 

Code:

  fun=@(block_struct)feature_extraction(block_struct.data);
  B=1 blockproc(g,[4 4],fun,'BorderSize',[3 3]);

Feature extraction function code

  function features=feature_extraction(name_images)
  [num_im,q]=size(name_images);
  features=zeros(num_im,12);
  for i=1:num_im
  A=imread(name_images(i,:));
  A=double(A);

  %Normalization of the pixels intensity in [0, N_gray-1]
  A=round((N_gray-1)*((A-min(A(:)))/(max(A(:))-min(A(:)))));

  features(i,1)=mean2(A);
  features(i,2)=std2(A);
  features(i,3)=skewness(A(:));
  features(i,4)=kurtosis(A(:));
  end

Kindly guide me what's wrong with it and how may I fix it. Is there any alternate way to do it?

Was it helpful?

Solution

You had better check your name_images. A=imread(name_images(i,:)); may cause the error if it is a structure instead of string.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top