There is a attach file of this project and screenshot of the problem. It is better to run the project and test yourself.

function btnRastr_Callback(hObject, eventdata, handles)
global PathName;
global FileName;
if FileName ~= 0
    FullN = [PathName FileName];
    try
        k = imread(FullN);
        gor = size(k,2);
        vert = size(k,1);
        r = k(:,:,1);
        g = k(:,:,2);
        b = k(:,:,3);
        dr = double(r);
        dg = double(g);
        db = double(b);
        dc = 1-dr/255;
        dm = 1-dg/255;
        dy = 1-db/255;
        var_k = ones(vert,gor);
          for i = 1:vert;
              for j = 1:gor;
                  if (dc(i,j) < var_k(i,j));
                      var_k(i,j) = dc(i,j);
                  end
                  if(dm(i,j) < var_k(i,j));
                      var_k(i,j) = dm(i,j);
                  end
                  if(dy(i,j) < var_k(i,j));
                      var_k(i,j) = dy(i,j);
                  end
                  if(var_k(i,j) == 1);
                      dc(i,j) = 0;
                      dm(i,j) = 0;
                      dy(i,j) = 0;
                  else
                      dc(i,j) = (dc(i,j)-var_k(i,j))/(1-var_k(i,j));
                      dm(i,j) = (dm(i,j)-var_k(i,j))/(1-var_k(i,j));
                      dy(i,j) = (dy(i,j)-var_k(i,j))/(1-var_k(i,j));
                  end
                  j = j+1;
              end
              i = i+1;
          end
          k = var_k;
          img = reshape(k,160000,[]);
          load network_one.mat
          a = network1(img);
          if a == 0
              set(handles.text1,'String','Портрет');
              rastr_fase(PathName, FileName);
          elseif a == 1
              load network_two.mat;
              b = network2(img);
              if b == 0
                  set(handles.text1,'String','Чертеж');
                  rastr_draw(PathName, FileName);
              elseif b == 1;
                  set(handles.text1,'String','Природа');
                  rastr_natur(PathName, FileName);
              end
          end
      catch exception
          errordlg('Ошибка чтения файлов!','Ошибка');
          rethrow(exception);
      end
  else errordlg('Не выбран файл!','Ошибка');
  end

답변 (1개)

Guillaume
Guillaume 2018년 4월 19일
편집: Guillaume 2018년 4월 19일

0 개 추천

Your image has 93274 pixels, it's probably a rectangle of 298x313 pixels. You're trying to reshape it into something that has 160000 rows. You don't even have enough pixels to fill one column of that something.

Your code is simply not design to work with images that size. You need to either use images that match the size your code expects (the number of pixels must be a multiple of 160000) or change your code so it works with images of any size.

댓글 수: 2

Andrey Fatuev
Andrey Fatuev 2018년 4월 19일
I want to change my code so it works with images of any size, but I don't know how(
Guillaume
Guillaume 2018년 4월 19일
Well, what is the purpose of that reshape? Why does the image has to be reshaped in 160000 rows exactly at the moment?

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

카테고리

도움말 센터File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

질문:

2018년 4월 19일

댓글:

2018년 4월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by