Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Gráficos
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 13-02-2008
schaka schaka is offline
Miembro
 
Registrado: feb 2008
Posts: 30
Poder: 0
schaka Va por buen camino
Filtro contraste

hola que tal ,tengo un problemita con unos filtros de imagenes con contrsate logaritmico y exponencial, cuando aplico el filtro me pone toda la imagen en negro, ya revise mi codigo y no le encuentro el porque, aqui les pongo mi filtro, espero me puedan ayudar el motivo de pk la pone toda en negro, gracias.
Código SQL [-]procedure TFMain.Contrastelog1Click(Sender: TObject);
var i,j,mayor, menor:integer;

begin mayor:=0; menor:=255; (*SE CALCULARA EL MAXIMO Y MINIMO PIXEL DE UNA IMAGEN Y SE LE ASIGNARA A PIXEL EL VALOR DE LA FORMULA DEL CONTRASTE*) for j := 0 to alto-1 do begin PLine := Bitmap.ScanLine[j]; i:=0; while i<=( (ancho*3)-1) do begin if ((PLine[i]+PLine[i+1]+PLine[i+2]) div 3) > mayor
then begin mayor:= ((PLine[i]+PLine[i+1]+PLine[i+2]) div 3) ; end; (*if mayor*)

if (PLine[i]+PLine[i+1]+PLine[i+2]div 3) < menor
then begin menor:= ((PLine[i]+PLine[i+1]+PLine[i+2]) div 3) ; end; (*if menor*)

if ( mayor+ menor )> 0
then begin pixel :=(mayor-menor)div( mayor+ menor ) ; end;

i:=i+3;
end; (*while*)
end; (*end for j*)



for j := 0 to alto-1 do begin PLine := Bitmap.ScanLine[j]; i:=0; while i<= (ancho*3)-1 do begin if PLine[i] <= 0 then PLine[i]:=1; PLine[i]:= 2*round(ln(pixel)+ln(PLine[i]))+5; if PLine[i] <= 0 then begin PLine[i]:=0; end;

if PLine[i] > 255 then begin PLine[i]:=255;end else begin PLine[i]:= 2*round(ln(pixel)+ln(PLine[i]))+5; end;

if PLine[i+1] <= 0 then PLine[i+1]:=1; PLine[i+1]:= 2*round(ln(pixel)+ln(PLine[i+1]))+5; if PLine[i+1] <= 0 then PLine[i+1]:=0; if PLine[i+1] > 255 then begin PLine[i+1]:=255;end else begin PLine[i+1]:= 2*round(ln(pixel)+ln(PLine[i+1]))+5; end;

if PLine[i+2] <= 0 then PLine[i+2]:=1; PLine[i+2]:= 2*round(ln(pixel)+ln(PLine[i+2]))+5; if PLine[i+2] <= 0 then PLine[i+2]:=0; if PLine[i+2] > 255 then begin PLine[i+2]:=255;end else begin PLine[i+2]:= 2*round(ln(pixel)+ln(PLine[i+2]))+5; end;

i:=i+3;
end;

end;

Image1.Picture.Assign(Bitmap);

end; (*begin metodo*)
Responder Con Cita
  #2  
Antiguo 13-02-2008
Avatar de Delphius
[Delphius] Delphius is offline
Miembro Premium
 
Registrado: jul 2004
Ubicación: Salta, Argentina
Posts: 5.582
Poder: 25
Delphius Va camino a la fama
Hola schaka, podrías editar el mensaje e incluir las etiquetas DELPHI por favor (y tabularlo mejor)? Es ilegible el código que expones.

De esta manera podré comprender mejor el código y ver donde puede estar el fallo.

Saludos,
__________________
Delphius
[Guia de estilo][Buscar]
Responder Con Cita
  #3  
Antiguo 13-02-2008
schaka schaka is offline
Miembro
 
Registrado: feb 2008
Posts: 30
Poder: 0
schaka Va por buen camino
Disculpa

ok , disculpa, aki va de nuevo

Código Delphi [-]
procedure TFMain.Contrastelog1Click(Sender: TObject);
var i,j,mayor, menor:integer;

begin mayor:=0; menor:=255; 

  (*SE CALCULARA  EL MAXIMO Y MINIMO PIXEL DE UNA IMAGEN Y
  SE LE ASIGNARA  A PIXEL EL VALOR DE LA FORMULA DEL CONTRASTE*) 

 for j := 0 to alto-1 do begin  
PLine := Bitmap.ScanLine[j];
 i:=0;  while i<=( (ancho*3)-1) do 
begin if ((PLine[i]+PLine[i+1]+PLine[i+2]) div 3) > mayor
then begin 
mayor:= ((PLine[i]+PLine[i+1]+PLine[i+2]) div 3) ;
end;   (*if mayor*)
 if (PLine[i]+PLine[i+1]+PLine[i+2]div 3) < menor
then begin 
menor:= ((PLine[i]+PLine[i+1]+PLine[i+2]) div 3) ;
end;   (*if menor*)
 if  ( mayor+ menor )> 0
then begin  pixel :=(mayor-menor)div( mayor+ menor ) ;
end;

i:=i+3;
end; (*while*)
 end;  (*end for j*)     
     for j := 0 to alto-1 do begin      
  PLine := Bitmap.ScanLine[j];      
    i:=0;       
while i<= (ancho*3)-1 do begin  
       if PLine[i] <= 0 then   
      PLine[i]:=1;   PLine[i]:= 2*round(ln(pixel)+ln(PLine[i]))+5;   
  
if PLine[i] <= 0 then  
  begin PLine[i]:=0; end;

  if PLine[i] > 255 then 
   begin PLine[i]:=255;end 

 else begin    PLine[i]:= 2*round(ln(pixel)+ln(PLine[i]))+5; end;

 if PLine[i+1] <= 0 then    
     PLine[i+1]:=1;  
 PLine[i+1]:= 2*round(ln(pixel)+ln(PLine[i+1]))+5; 

 if PLine[i+1] <= 0 then   
  PLine[i+1]:=0;  
 
 if PLine[i+1] > 255 then    
 begin PLine[i+1]:=255;end  

else begin    PLine[i+1]:= 2*round(ln(pixel)+ln(PLine[i+1]))+5;
 end;

 if PLine[i+2] <= 0 then   
      PLine[i+2]:=1;   PLine[i+2]:= 2*round(ln(pixel)+ln(PLine[i+2]))+5; 
 if PLine[i+2] <= 0 then  
   PLine[i+2]:=0;   
 if PLine[i+2] > 255 then    
 begin PLine[i+2]:=255;end 
 else begin PLine[i+2]:= 2*round(ln(pixel)+ln(PLine[i+2]))+5; end;

      i:=i+3;
      end;

      end;

      Image1.Picture.Assign(Bitmap);

      end;    (*begin metodo*)
Responder Con Cita
  #4  
Antiguo 13-02-2008
Avatar de Delphius
[Delphius] Delphius is offline
Miembro Premium
 
Registrado: jul 2004
Ubicación: Salta, Argentina
Posts: 5.582
Poder: 25
Delphius Va camino a la fama
Muchas gracias schaka,
Ahora se ve algo mejor.

Tengo que comparar al algoritmo que tienes con mis apuntes... si a ese algoritmo lo estudiaste o sacaste de algún lado puede que resulte de utilidad que nos cite la fuente.

Como no tengo muy a mano mis apuntes en estos momentos es probable que me demore. Supongo que no hay problema con ello...

Veo que haz colocado una variable pixel y no está declarada allí... ¿es global?
Noto además que no haces una comprobación del formato y de los bits que usa. Supongo que estás trabajando directamente con imagenes bmp y de 24 bits.

El problema del color a negro, a simple vista no le hallo causa... a menos que sea un error humano y hayas invertido el sentido de alguna operación.

Saludos,
__________________
Delphius
[Guia de estilo][Buscar]
Responder Con Cita
  #5  
Antiguo 13-02-2008
schaka schaka is offline
Miembro
 
Registrado: feb 2008
Posts: 30
Poder: 0
schaka Va por buen camino
Muchas gracias, bueno pues el metodo me lo he ideado, ya que la unica informacion que tengo para realizar un contraste por medio de logaritmo es una formula :


y=b*log(mx)+c , "b" y "c" son constantes , "X" el el valor de mi pixel o canal, "Y" es el canal o pixel al que le aplico el cambio

m=(a-b)/(a+b) a es el valor del pixel mas grande y b el mas chico

hojala puedas ayudarme proporcionandome un metodo para poder hacer este contraste

Última edición por schaka fecha: 13-02-2008 a las 20:29:07.
Responder Con Cita
  #6  
Antiguo 13-02-2008
Avatar de Delphius
[Delphius] Delphius is offline
Miembro Premium
 
Registrado: jul 2004
Ubicación: Salta, Argentina
Posts: 5.582
Poder: 25
Delphius Va camino a la fama
Ummm.... La función que yo conozco es de la forma:

q = L x ln( 1 + p) / ln( 1 + L)

siendo L el máximo valor que toma un pixel en la imagen
p el valor actual
ln: la función logaritmo natural.

Aunque creo haber visto en algún lado la función que tu comentas.
Creo que por allí viene la mano.

Me tengo que retirar por ahora, si puedo en unas horas vuelvo.
Saludos,
__________________
Delphius
[Guia de estilo][Buscar]
Responder Con Cita
  #7  
Antiguo 13-02-2008
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Poder: 24
seoane Va por buen camino
A primera vista aquí hay un error:
Código Delphi [-]
while i<=( (ancho*3)-1) do
Cuando debería de ser:
Código Delphi [-]
while i<=( (ancho-1)*3) do

Luego me parece que esta comparación siempre es verdadera, al tratarse siempre de números positivos:
Código Delphi [-]
if  ( mayor+ menor )> 0

Vete corrigiendo eso, y luego ya veremos
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Filtro en tabla cidemente Varios 0 07-06-2007 17:17:15
Ayuda con filtro vhirginia Conexión con bases de datos 10 27-04-2004 21:48:20
Mal filtro vicrati Conexión con bases de datos 2 11-04-2004 19:36:51
Filtro manu Conexión con bases de datos 2 19-11-2003 15:36:57
Filtro y EOF javiermorales Conexión con bases de datos 2 07-10-2003 15:28:08


La franja horaria es GMT +2. Ahora son las 02:59:40.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi