Home Why my function in octave or matlab doesn't have the propper scope
Reply: 0

Why my function in octave or matlab doesn't have the propper scope

user3199
1#
user3199 Published in April 26, 2018, 5:46 am

I have the following script and the line of "endwhile %end sensibility" my function loses the scope i am wondering why this happen? I make sure to enclose every loop and condition whit its respective ends.

Here is the code of the function that i have been tried to getting work.

function grandPictureEnd = grandPicture (numberOfElements, routeOfFolder)



for iteration = 1:1:numberOfElements
    n = getNumberElementsInsideFolder('bills');
    imageName = getSingleNameOfElementInsideFolder('bills', iteration) 
    imageRoute = [pwd,'/Pictures/',routeOfFolder,'/',imageName];
    image = imread (imageRoute); %Especificar la imagen y directorio
    [X,map] = rgb2ind(image); %transforma la imagen RGB a una imagen tipo indexed
    grayImage = ind2gray(X,map); %transforma a una imagen de grises

    %transform to binary
    binaryOk = 0;
    while (~binaryOk)
      binary = input("Input the binary boundary= ");
      binaryImage = im2bw(grayImage,binary); % transforma a una imagen binaria
      binaryImage = not(binaryImage); % aplica la negaciĆ³n a la imagen, ya que las letras deben estar en blanco y el fondo negro
      imshow(binaryImage);
      binaryOk = input("Is the binary boundary OK= ");
    endwhile %end binary

    %Sensibility
    sensibilityOk = 0;
    while (~sensibilityOk)
      sensibility = input("Input sensibility= ");
      se = strel('square', sensibility); %sensibilidad de seleccion para seleccionar la figura 7, tipo cuadraado
      imClose = imclose(binaryImage, se); %aplicar la seleccion a la imagen binaria 
      s = regionprops(imClose, 'BoundingBox'); %crea el rectangulo mas  cerrado para la seleccion de las letras
      bb = round(reshape([s.BoundingBox], 4, []).'); %Obtener las coordenadas de las cajas

      imshow(grayImage);  
      for idx = 1 : numel(s)
        hold on
        rectangle('Position', bb(idx,:), 'edgecolor', 'red'); %crea los rectangulos de color rojo
      endfor

      sensibilityOk = input("Is the sensibility OK= ");
    endwhile %end sensibility

    lettersOk = input("Were the letters getting = ");

    if (lettersOk)
      %Taking the lines of the gray Image
      chars = cell(1, numel(s));
      for idx = 1 : numel(s)
        chars{idx} = grayImage(bb(idx,2):bb(idx,2)+bb(idx,4)-1, bb(idx,1):bb(idx,1)+bb(idx,3)-1); %obtienen las secciones de las imagenes dentro del rectangulo
        imwrite(chars{idx}, [pwd,'/Pictures/lettersGray/',int2str(iteratorImage),'.jpg']);
        iteratorImage = iteratorImage +1;
      endfor
        %delete(imageRoute); %eliminate this image 
        iteratorImage = iteratorImage + 1000;
    else
      %delete(imageRoute); %eliminate this image 
      %Taking the lines of the gray Image
      chars = cell(1, numel(s));
      for idx = 1 : numel(s)
        chars{idx} = grayImage(bb(idx,2):bb(idx,2)+bb(idx,4)-1, bb(idx,1):bb(idx,1)+bb(idx,3)-1); %obtienen las secciones de las imagenes dentro del rectangulo
        imwrite(chars{idx}, [pwd,'/Pictures/bills/',int2str(iteratorImage),'.jpg']);
        iteratorImage = iteratorImage +1;
      endfor
        iteratorImage = iteratorImage + 1000;
    endif   
  endfor
endfunction
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.306891 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO