Manejar archivos DICOM




DICOM (Digital Imaging and Communication in Medicine) es el estándar reconocido mundialmente para el intercambio de imágenes médicas, pensado para el manejo, almacenamiento, impresión y transmisión de imágenes médicas.

Mas abajo pueden descargarse un conversor de archivos en formato DICOM a bmp, jpg o png y un visor de imágenes que incluye el objeto ActiveX ezDICOMax.ocx.

Para instalarlo:
Desde Delphi seleccionar 'Import ActiveX Control' desde el menú "component" y después pulsar "Add" y "Install" seleccionado el archivo DCMaxPro.OCX que está incluido en la carpeta.
Una vez que se ha instalado correctamente se debería ver el componente "DCMax" en la pestaña "ActiveX" de la barra de componentes.

Si da un error del tipo "eOlesyserror" es porque no se ha registrado el activex llamado ezDICOMax.ocx
Para instalarlo teclear:    c:\regsvr32 ezDICOMax.ocx
y para desinstalarlo  c:\regsvr32   /u   ezDICOMax.ocx 
 

Codigo fuente en Delphi :
Conversor de imagenes DICOM a bmp,jpg,png

Autor:  Wolfgang Krug and Chris Rorden
chris.rorden@nottingham.ac.uk

Visor de imagenes

PROCEDIMIENTOS DEL PROGRAMA

procedure TForm1.ToolClick(Sender: TObject);
begin
     DCMax1.DCMtool := (sender as TSpeedButton).tag;
end;

procedure TForm1.Exit1Click(Sender: TObject);
begin
  Close;
end;

procedure TForm1.Open1Click(Sender: TObject);
begin
     if not OpenDialog1.execute then exit;
     DCMax1.DCMfilename := OpenDialog1.Filename;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  DCMax1.DCMtoolbar := false;
  Smooth1.Checked := DCMax1.DCMsmoothOn;
end;

procedure TForm1.N2001Click(Sender: TObject);
var lPct: integer;
begin
     (Sender as TMenuItem).Checked := true;
     lPct := (Sender as TMenuItem).tag;
     if lPct = 0 then begin
         if not DCMax1.DCMbestFitZoom then
            DCMax1.DCMbestFitZoom := true;
     end else begin
         if DCMax1.DCMbestFitZoom then
            DCMax1.DCMbestFitZoom := false;
         DCMax1.DCMzoomPct := lPct;
     end;

end;

procedure TForm1.Smooth1Click(Sender: TObject);
begin
  Smooth1.Checked := not Smooth1.Checked;
  DCMax1.DCMsmoothOn := Smooth1.Checked;
end;

procedure TForm1.InvertedHotmetal1Click(Sender: TObject);
begin
     (Sender as TMenuItem).Checked := true;
     DCMax1.DCMcolorscheme := (Sender as TMenuItem).tag;
end;

procedure TForm1.N3x3Click(Sender: TObject);
var lMosaic: integer;
begin
    lMosaic := (Sender as TMenuItem).tag;
    (Sender as TMenuItem).checked := true;
    //Form1.caption := inttostr(lMosaic);
    DCMax1.DCMmosaicFirstSlice := 1;
    DCMax1.DCMmosaicLastSlice := maxint;
    DCMax1.DCMmosaicRows := lMosaic;
    DCMax1.DCMmosaicCols := lMosaic;

    //DCMax1.DCMmosaicX[lMosaic,lMosaic,1] := MaxInt;
    //DCMax1.DCMmosaicX[2,2,1,16];
    //xxxx
end;

procedure TForm1.DelphiDemo1Click(Sender: TObject);
begin
 showmessage('DelphiDemo by Chris Rorden. Demonstrates ezDICOM ActiveX component. '+
  DCMax1.DCMversionInfo);
end;

procedure TForm1.ShowHeader1Click(Sender: TObject);
begin
  ShowHeader1.Checked := not ShowHeader1.Checked;
  DCMax1.DCMshowHeader := ShowHeader1.Checked;
end;

procedure TForm1.Copy1Click(Sender: TObject);
begin
  if DCMax1.DCMshowHeader then
    DCMax1.DCMcopyHeader2Clipboard
  else
    DCMax1.DCMcopyImage2Clipboard;
end;

procedure TForm1.Saveimage1Click(Sender: TObject);
begin
     if not SaveDialog1.Execute then exit;
     DCMax1.DCMsaveToFile := SaveDialog1.FileName;
end;

procedure TForm1.Border1Click(Sender: TObject);
begin
 // DCMax1.DCMmo
end;

procedure TForm1.Unloadimages1Click(Sender: TObject);
begin
end;
(*procedure TForm1.Loadc0020dcm50times1Click(Sender: TObject);
var lInc: integer;
begin
  for lInc := 1 to 50 do
    DCMax1.DCMfilename := 'C:\0020.dcm';
end;

procedure TForm1.Unloadimages1Click(Sender: TObject);
begin
  DCMax1.DCMunloadImages:= 0;
end;
*)
procedure TForm1.PreviousSliceItemClick(Sender: TObject);
begin
  if DCMax1.DCMslice > 1 then
    DCMax1.DCMslice := DCMax1.DCMslice -1
  else
    DCMax1.DCMslice := DCMax1.DCMimageSlices;
end;

procedure TForm1.NextSliceItemClick(Sender: TObject);
begin
  if DCMax1.DCMslice < DCMax1.DCMimageSlices then
    DCMax1.DCMslice := DCMax1.DCMslice +1
  else
    DCMax1.DCMslice := 1;
end;

procedure TForm1.DCMax1DCMmouseMoveIntensity(ASender: TObject; X, Y,
  Button, Shift, Intensity: Integer; RGB: WordBool);
begin
  Caption := inttostr(X)+','+inttostr(Y)+':'+inttostr(intensity);
end;



Relacionados:
Componente para generar efectos graficos
Librería Exif
Componente para manipulacion de imagenes
Morphing con delphi

Trucos sobre imagenes 







Delphi y Arduino


Aquí tienen 2 programas que permiten controlar desde Delphi la placa de hardware arduino, uno es para leer la temperatura desde el sensor LM35 y el otro para apagar y encender unos leds.
Buscando en la red también encontré esta página donde explica cómo se interconecta el sensor LM35.
Autor: Roberto Ramirez

Descargar programa para leer la temperatura

Relacionados:
Osciloscopio con la tarjeta de sonido
Visualizar el espectro de las frecuencias de sonido 
Vumetro con Delphi


PROGRAMA PARA CONTROLAR LEDs
{*
 * Delphi LEDs Control
 * -----------------
 * Controls the state (ON/OFF) of 5 LEDs connected to an Arduino Board
 * on Digital Pins 2,3,4,5,6 thru the serial comm
 *
 * Created April 02 2009
 * copyleft 2009 Roberto Ramirez
 * Full Source code at http://www.thepenguincult.com/proyectos/arduino-delphi-control/
 *
 *}

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, CPort, CPortCtl, Menus;

type
  TForm1 = class(TForm)
    btn_connect: TButton;
    ComPort1: TComPort;
    StatusBar1: TStatusBar;
    btn_Setup: TButton;
    chk_led1: TCheckBox;
    chk_led2: TCheckBox;
    chk_led3: TCheckBox;
    chk_led4: TCheckBox;
    chk_led5: TCheckBox;
    btn_loop: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    procedure btn_connectClick(Sender: TObject);
    procedure btn_SetupClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure chk_led1Click(Sender: TObject);
    procedure chk_led2Click(Sender: TObject);
    procedure chk_led3Click(Sender: TObject);
    procedure chk_led4Click(Sender: TObject);
    procedure chk_led5Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure btn_loopClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btn_connectClick(Sender: TObject);
begin
  if ComPort1.Connected then
      begin

      btn_connect.Caption:='Connect';  // Toggle the caption of Connection Button
      btn_Setup.Enabled:=True;         // If not connected, lets enable the Setup Button
      btn_loop.Enabled:=false;         // Knight Rider demo button is disabled at first

      // This block resets the state of all Leds to Off
      // According to Arduino Code the Chars A,B,C,D,E are used
      // to set Digital Pins (2-6) to LOW
      comport1.WriteStr('A');
      comport1.WriteStr('B');
      comport1.WriteStr('C');
      comport1.WriteStr('D');
      comport1.WriteStr('E');
      //-----------------------------------------------
      // This block resets the state of all Check Boxes to Unchecked
      chk_led1.Checked:=false;
      chk_led2.Checked:=false;
      chk_led3.Checked:=false;
      chk_led4.Checked:=false;
      chk_led5.Checked:=false;
      //-----------------------------------------------
      ComPort1.Close;                  // COM Port in use is closed

      statusbar1.Panels[1].Text:='Disconnected';  // Status bar is set to display connection info

      // This block disables the check boxes
      // so the user cannot change them if COM Port is disconnected
      chk_led1.Enabled:=false;
      chk_led2.Enabled:=false;
      chk_led3.Enabled:=false;
      chk_led4.Enabled:=false;
      chk_led5.Enabled:=false;
      //------------------------------------------------
     end

    else
      begin
      btn_connect.Caption:='Disconnect';        // Toggle the caption of Connection Button
      btn_Setup.Enabled:=False;                 // If not connected, lets disable the Setup Button
      btn_loop.Enabled:=true;                   // Now that conection is posible Knight Rider demo button is enabled
      ComPort1.Open;                            // COM Port in use is finally opened
      statusbar1.Panels[1].Text:='Connected';   // Status bar is set to display connection info

      // This block enables the check boxes
      // so the user can change them to set LED states when COM Port is connected
      chk_led1.Enabled:=true;
      chk_led2.Enabled:=true;
      chk_led3.Enabled:=true;
      chk_led4.Enabled:=true;
      chk_led5.Enabled:=true;
      //------------------------------------------------
      end
end;



procedure TForm1.btn_SetupClick(Sender: TObject);
begin
comport1.ShowSetupDialog;                                   // Opens the predefined Setup Dialog (part of ComPort component)
statusbar1.Panels[0].Text:='Port in use ' + comport1.Port;  // Status bar is set to display Port in use after setup dialog
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
statusbar1.Panels[0].Text:='Port in use ' + comport1.Port;  // Status bar is set to display predefined Port in use at begining of program execution

  if comport1.Connected=true then
    statusbar1.Panels[1].Text:='Connected'                  // Status bar is set to display connection info at begining of program execution
    else
    statusbar1.Panels[1].Text:='Disconnected'
  end;


// Next are the procedures to turning ON and OFF each led using the variables
// defined on both Arduino code and delphi code.
// Sending the predifined vars thru serial comm (on byte at the time)
// Ports 2,3,4,5,6 are turned ON by sending it corresponding var 1,2,3,4,5
// and they are turned OFF by sending it corresponding var A,B,C,D,E


procedure TForm1.chk_led1Click(Sender: TObject);
begin

    if chk_led1.Checked=true then
    comport1.WriteStr('1')
    else
    comport1.WriteStr('A')

end;

procedure TForm1.chk_led2Click(Sender: TObject);
begin
    if chk_led2.Checked=true then
    comport1.WriteStr('2')
    else
    comport1.WriteStr('B')
end;

procedure TForm1.chk_led3Click(Sender: TObject);
begin
    if chk_led3.Checked=true then
    comport1.WriteStr('3')
    else
    comport1.WriteStr('C')
end;

procedure TForm1.chk_led4Click(Sender: TObject);
begin
    if chk_led4.Checked=true then
    comport1.WriteStr('4')
    else
    comport1.WriteStr('D')
end;

procedure TForm1.chk_led5Click(Sender: TObject);
begin
    if chk_led5.Checked=true then
    comport1.WriteStr('5')
    else
    comport1.WriteStr('E')
end;

// Here ends the ON/OFF procedures for each led


procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if ComPort1.Connected then
      begin
        comport1.WriteStr('A');     // If the application is closed, its good to leave
        comport1.WriteStr('B');     // everything as we found it at start.
        comport1.WriteStr('C');     // So we reset all the leds to OFF
        comport1.WriteStr('D');
        comport1.WriteStr('E');
        ComPort1.Close;
        end
end;

procedure TForm1.btn_loopClick(Sender: TObject);
begin

// We turn off all Led Check Boxes to allow a clean state before and after Knight Rider Demo mode
      chk_led1.Checked:=false;
      chk_led2.Checked:=false;
      chk_led3.Checked:=false;
      chk_led4.Checked:=false;
      chk_led5.Checked:=false;


// Here begins the rough mode of Knight Rider Demo ;)

        comport1.WriteStr('1');
        Sleep(50);
        comport1.WriteStr('A');
        Sleep(50);
        comport1.WriteStr('2');
        Sleep(50);
        comport1.WriteStr('B');
        Sleep(50);
        comport1.WriteStr('3');
        Sleep(50);
        comport1.WriteStr('C');
        Sleep(50);
        comport1.WriteStr('4');
        Sleep(50);
        comport1.WriteStr('D');
        Sleep(50);
        comport1.WriteStr('5');
        Sleep(50);
        comport1.WriteStr('E');
        Sleep(50);

        comport1.WriteStr('4');
        Sleep(50);
        comport1.WriteStr('D');
        Sleep(50);
        comport1.WriteStr('3');
        Sleep(50);
        comport1.WriteStr('C');
        Sleep(50);
        comport1.WriteStr('2');
        Sleep(50);
        comport1.WriteStr('B');
        Sleep(50);
        comport1.WriteStr('1');
        Sleep(50);
        comport1.WriteStr('A');
        Sleep(50);
end;

end.



Librería Exif

Biblioteca de funciones para crear, editar y modificar los metadatos exif y ipctc en archivos de imágenes con formato jpg.



Autor:
Chris Rolliston (http://delphihaven.wordpress.com/).

Licence:
MPL 1.1 (text at http://www.mozilla.org/MPL/MPL-1.1.html).

Features

·        Exif parsing is 100% pure Delphi code — doesn’t use (say) LibExif or LibTiff, GDI+, WIC, or even Windows.pas.

·        Reads and writes both small- and big-endian data.

·        Surfaces both standard Exif and Windows Explorer tags, and provides access to the tags of some maker note types too.

·        Doesn’t corrupt internal maker note offsets when data is rewritten, and takes account of the Microsoft-defined OffsetSchema tag.

·        Can optional write XMP data as per the XMP Exif schema.

·        Includes an IPTC reader/writer class as well.





El juego de las líneas en 3D


 Juego interesante, adictivo y muy bien programado.

Autor: Alexander Izmukhambetov 

Juego de damas avanzado

Aquí tienen el conocido juego de las damas. Tiene como opción la posibilidad de jugar humano-máquina, máquina-máquina, giro de tablero y varios niveles (beginer, intermediate, expert).