FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
#1
|
|||
|
|||
Histograma
Hola a todos,
estoy realizando una aplicación para la generación de imágenes en 3D: http://imagen3d.site88.net/ Esta aplicación muestra un histograma donde se muestran los valores de los tres componentes de color primarios (Rojo, Azul y Verde). http://imagen3d.site88.net/img/ayuda9.jpg El código que utilizo para generar el histograma es el siguiente: Código:
CONST MaxPixelCount = 32768; TYPE pRGBTripleArray = ^TRGBTripleArray; // Use SysUtils.pByteArray for 8-bit color TRGBTripleArray = ARRAY[0..MaxPixelCount-1] OF TRGBTriple; procedure TFormSide.Action1Execute(Sender: TObject); var i,j : integer; Row: pRGBTripleArray; BmpSbS : TBitmap; //Histograma HRa,HBa,HGa: array[1..256] of integer; //Componentes del histograma R,G,B,Color : integer; begin //Reinicia Histograma FillChar(HRa,Sizeof(HRa),#0); FillChar(HGa,Sizeof(HGa),#0); FillChar(HBa,Sizeof(HBa),#0); BmpSbS := TBitmap.Create; TRY //Utilizo la librería gráficos LibGFL de XnView para cargar las imágenes //gfl_bmpSbS contiene la imagen a mostrar en pantalla BmpSbS.PixelFormat := pf24bit; BmpSbS.Width := gfl_bmpSbS.Width;// Ancho de la imagen BmpSbS.Height := gfl_bmpSbS.Height;//Alto de la imagen FOR j := 0 TO BmpSbS.Height-1 DO BEGIN Row := BmpSbS.Scanline[j]; FOR i := 0 TO BmpSbS.Width-1 DO BEGIN gflGetColorAt(gfl_bmpSbS,i,j,Pgfl_colorSbS);//Obtiene el valor de las componentes RGB WITH Row[i] DO BEGIN rgbtRed := pgfl_colorSbS.Red; rgbtBlue := pgfl_colorSbS.Blue; rgbtGreen := pgfl_colorSbS.Green; //Histrograma inc(HRa[rgbtRed]); inc(HGa[rgbtGreen]); inc(HBa[rgbtBlue]); END END END; FormSide.Image1.Picture.Graphic := BmpSbS; // Muestra la imagen PanelPImagen1.Width := BmpSbS.Width + 2; PanelPImagen1.Height := BmpSbS.Height + 2; FINALLY BmpSbS.Free; //Libera Memoria END; //Histograma //Hay que calcular el valor máximo siempre y cuando HmaxSideCal sea TRUE. Esto lo realizo para que sólo se realice el cálculo la primera vez que se muestra //la imagen y no cada vez que variemos la saturación, el contraste, etc... de la imagen if HmaxSideCal then begin HMaxSideCal := False; //Para que no se vuelva a calcular el valor máximo del Histograma HmaxSide:= 1; for i:= 1 to 256 do begin if HRa[i] > HmaxSide then HmaxSide:= HRa[i]; if HGa[i] > HmaxSide then HMaxSide:= HGa[i]; if HBa[i] > HmaxSide then HmaxSide:= HBa[i]; end; end; ImageHa.Canvas.FillRect(ImageHa.Canvas.ClipRect); //Muestra el Histograma for i:= 1 to 256 do begin HRa[i] := Trunc((HRa[i] / HmaxSide) * 100); HGa[i] := Trunc((HGa[i] / HmaxSide) * 100); HBa[i] := Trunc((HBa[i] / HmaxSide) * 100); for j := 1 to 256 do begin if j > HRa[i] then R := 0 else R := 255; if j > HGa[i] then G := 0 else G := 255; if j > HBa[i] then B := 0 else B := 255; if (R = 0) and (G = 0) and (B = 0) then Color := RGB(64,64,64) // else Color := RGB(R,G,B); ImageHa.Canvas.Pixels[i-1,101-j] := Color; end; end; end; ¿A alguien se le ocurre alguna fórmula para aumentar la velocidad al mostrar el histograma? Última edición por madiazg fecha: 05-07-2008 a las 23:14:31. |
#2
|
||||
|
||||
Es un poco dificil ayudar cuando no se "tiene" el código completo; "undeclared identifier; pRGBTripleArray" !!! y bueno tambien vale la pena comentar el mismo problema acerca de las variables globales!
Eh aqui una posible solucion... tiene alguna falla pero no la puedo probar con el "original", por lo anteriormente comentado!
Toma una atencion principal en la cantidad de bucles; y en el uso del ScanLine. Un Saludo |
#3
|
|||
|
|||
Hola,
gracias por el interés mostrado. He editado mi primer mensaje para añadir pRGBTripleArray y aclarar un poco más el código que utilizo para mostrar el histograma. Estudiaré el código que me han enviado para ver si saco algo en claro porque la verdad es que me supera un poco. Saludos... Miguel Angel |
#4
|
||||
|
||||
Cita:
La idea es poder reproducir dicha funcion en un proyecto en limpio para rehacerlo (como ya lo habras notado en mi anterior post). Si te continua dando mucha "lata", aclarame lo anterior a ver que se puede hacer PD; el histograma solo se puede sacar de dos imagenes? las dos imagenes se deben entrelazar? Saludos |
#5
|
|||
|
|||
Hola,
para el desarrollo del programa estoy utilizando la librería gráfica GFL SDK. En esta librería se define la función gflGetColorAt: Cita:
Cita:
Cita:
HMaxSide es el valor máximo del histograma, y es del tipo integer. GFL_SDK es una librería desarrollada en C y me da algunos quebraderos de cabeza que todavía no he podido resolver (como la obtención de los datos EXIF de una fotografía, lo Metadatos, etc...). Aún así, es muy potente a la hora de 'gestionar' fotografías, tal y como queda demostrado en la aplicación XnView. Saludos y gracias por el interés... Miguel Angel |
|
|
Temas Similares | ||||
Tema | Autor | Foro | Respuestas | Último mensaje |
Histograma en Delphi | Cesar Junior | Gráficos | 10 | 05-07-2012 12:36:42 |
Histograma. Obtener máximos y mínimos relativos | Delphius | Varios | 7 | 16-04-2007 12:12:46 |
Histograma | javikanin | Varios | 16 | 02-01-2006 23:40:17 |
Graph Meter (histograma) | cadena | Gráficos | 0 | 01-12-2004 19:29:23 |
|