help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: speed problem


From: elier
Subject: Re: speed problem
Date: Sat, 23 Jun 2012 18:13:40 -0700 (PDT)

Thanks for your quick reply, and sorry from my english in some cases.
I ran the new script in both, octave and matlab,  in octave it takes almost
5 minuts more than in matlab.
The scripts its very simple:
I read from a text file the addresses of some images, all of them 8-bit
grayscale (satellite images)
Apply a grid using matrix substraction
Using a conditional matrix I make all the elements over a threshold value =
255
THIS WAS THE FAST PART THE ITS COMES THE SLOW ONE

For a range of values (between umbralmin and unmbralmax) I check if the
element is greater than the median of the elements of a 9 x 9 matrix
centered in it (excluding 0 and 255).
I use the find function to reduce the amount of elements to check, but in my
case they are about 100000-130000. I tried to avoid all the loops but in
some cases I could't.
************************************************
[i_mediana,j_mediana]= find (imagen_lista>=umbralmin &
imagen_lista<=umbralmax);
 for k=1:length(i_mediana) 
  borde_der=j_mediana(k)+puntos;
  borde_izq=j_mediana(k)-puntos;
  borde_sup=i_mediana(k)-puntos;
  borde_inf=i_mediana(k)+puntos;
  if(borde_sup<=0)
    borde_sup=1;
  end   
  if(borde_inf>=617)
    borde_inf=617;
  end
  if(borde_izq<=0)
    borde_izq=1;
  end
  if(borde_der>=1024)
   borde_der=1024;
  end    
  recorte=imagen_lista(borde_sup:borde_inf,borde_izq:borde_der);
  vector=recorte.*uint8(recorte~=255 & recorte~=0);
  [i,j,valores]=find(vector);
  mediana=median(valores);
  if (mediana<=imagen_lista(i_mediana(k),j_mediana(k)))
   imagen_lista(i_mediana(k),j_mediana(k))=255;
  end
 end

************************************************
 This step is repeated for every image, later I get an average image for all
the list, and using an algorithm similar to the median I calculate the mean
of a 5x5 matrix in order to smooth the image.
 This last step I made only once but for a bigger amount of elements (almost
400000)
 I really thank you for your concern and I hope than some can make a
suggetion to improve it.

--
View this message in context: 
http://octave.1599824.n4.nabble.com/speed-problem-tp4630822p4630898.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]