AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi Simulate infrared film
Thema durchsuchen
Ansicht
Themen-Optionen

Simulate infrared film

Ein Thema von WojTec · begonnen am 28. Nov 2010 · letzter Beitrag vom 29. Nov 2010
Antwort Antwort
Seite 1 von 2  1 2      
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#1

Simulate infrared film

  Alt 28. Nov 2010, 18:19
Hi,

I'm interesing in nice photo effect - infrared film. I want to implement this cool effect, but I don't found any informations how to make it. Do you know something about it?
  Mit Zitat antworten Zitat
Medium

Registriert seit: 23. Jan 2008
3.679 Beiträge
 
Delphi 2007 Enterprise
 
#2

AW: Simulate infrared film

  Alt 28. Nov 2010, 22:23
I think you need to elaborate a bit more, or show examples of what you have in mind. Extracting actual IR infos from normal computer images is obviously impossible, though there are some CCD chips out there, that respond to IR sources. But how this manifests in the RGB domain is entirely arbitrary, and should not yield any usable data. Hence what you think of needs to be some sort of a fake-IR filter, for which there is no standard, and needs way more explanation from your side.
"When one person suffers from a delusion, it is called insanity. When a million people suffer from a delusion, it is called religion." (Richard Dawkins)
  Mit Zitat antworten Zitat
Benutzerbild von Bummi
Bummi

Registriert seit: 15. Jun 2010
Ort: Augsburg Bayern Süddeutschland
3.470 Beiträge
 
Delphi XE3 Enterprise
 
#3

AW: Simulate infrared film

  Alt 28. Nov 2010, 22:24
via Bitmap Scanline
eliminate blue
increase green * 2
convert to gray

Call
Delphi-Quellcode:
  InfraRed(Image1.Picture.Bitmap);
  Image1.Invalidate;
May be adapted for your needs

Delphi-Quellcode:
unit EXBMP_Utils_1;
// 201011 by Thomas Wasseermann

interface

uses Windows,Classes, Graphics;



type
  pRGBTripleArray = ^TRGBTripleArray;
  TRGBTripleArray = ARRAY[0..$effffff] OF TRGBTriple;
  pRGBQuadArray = ^TRGBQuadArray;
  TRGBQuadArray = ARRAY[0..$effffff] OF TRGBQuad;


  procedure ConvertBitmapToGrayscale(const Bitmap: TBitmap);
  Procedure InfraRed(bmp:TBitmap);

implementation
  
procedure ConvertBitmapToGrayscale32(const Bitmap: TBitmap);
type
  PPixelRec = ^TPixelRec;
  TPixelRec = packed record
    B: Byte;
    G: Byte;
    R: Byte;
    Reserved: Byte;
  end;
var
  X: Integer;
  Y: Integer;
  P: PPixelRec;
  Gray: Byte;
begin
  for Y := 0 to (Bitmap.Height - 1) do
  begin
    P := Bitmap.ScanLine[Y];
    for X := 0 to (Bitmap.Width - 1) do
    begin
      Gray := Round(0.30 * P.R + 0.59 * P.G + 0.11 * P.B);
      P.R := Gray;
      P.G := Gray;
      P.B := Gray;
      Inc(P);
    end;
  end;
end;

procedure ConvertBitmapToGrayscale24(const Bitmap: TBitmap);
type
  PPixelRec = ^TPixelRec;
  TPixelRec = packed record
    B: Byte;
    G: Byte;
    R: Byte;
  end;
var
  X: Integer;
  Y: Integer;
  P: PPixelRec;
  Gray: Byte;
begin
  for Y := 0 to (Bitmap.Height - 1) do
  begin
    P := Bitmap.ScanLine[Y];
    for X := 0 to (Bitmap.Width - 1) do
    begin
      Gray := Round(0.30 * P.R + 0.59 * P.G + 0.11 * P.B);
      P.R := Gray;
      P.G := Gray;
      P.B := Gray;
      Inc(P);
    end;
  end;
end;


procedure ConvertBitmapToGrayscale(const Bitmap: TBitmap);

begin
  if Bitmap.PixelFormat = pf32Bit then ConvertBitmapToGrayscale32(Bitmap)
  else if Bitmap.PixelFormat = pf24Bit then ConvertBitmapToGrayscale24(Bitmap);
end;




Function GetDoubleByte(i:Integer):Integer;
  Begin
    Result := i * 2;
    if Result > 255 then Result := 255;
  End;

Procedure InfraRed24(bmp:TBitmap);
var
 pscanLine : pRGBTripleArray;
 x,y:Integer;
begin
  for y := 0 to bmp.Height - 1 do
    begin
       pscanLine := bmp.Scanline[y];
       for x := 0 to bmp.Width - 1 do
          begin
              pscanLine[x].rgbtBlue := 0;
              pscanLine[x].rgbtGreen := GetDoubleByte(pscanLine[x].rgbtGreen);
          end;
    end;
  ConvertBitmapToGrayscale(bmp);
end;

Procedure InfraRed32(bmp:TBitmap);
var
 pscanLine : pRGBQuadArray;
 x,y:Integer;
begin
  for y := 0 to bmp.Height - 1 do
    begin
       pscanLine := bmp.Scanline[y];
       for x := 0 to bmp.Width - 1 do
          begin
              pscanLine[x].rgbBlue := 0;
              pscanLine[x].rgbGreen := GetDoubleByte(pscanLine[x].rgbGreen);
          end;
    end;
  ConvertBitmapToGrayscale(bmp);
end;


Procedure InfraRed(bmp:TBitmap);
begin
  if bmp.PixelFormat=pf32Bit then InfraRed32(bmp)
  else if bmp.PixelFormat=pf24Bit then InfraRed24(bmp);
end;

end.
Thomas Wassermann H₂♂
Das Problem steckt meistens zwischen den Ohren
DRY DRY KISS
H₂ (wenn bei meinen Snipplets nichts anderes angegeben ist Lizenz: WTFPL)

Geändert von Bummi (29. Nov 2010 um 15:32 Uhr) Grund: Byteüberlauf
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#4

Re: Simulate infrared film

  Alt 29. Nov 2010, 11:12
What exactly I'm mean you can see on attached image.

@Bummi, thanks for your filter, it's interesting too
Miniaturansicht angehängter Grafiken
what_i_mean.jpg  
  Mit Zitat antworten Zitat
Benutzerbild von Bummi
Bummi

Registriert seit: 15. Jun 2010
Ort: Augsburg Bayern Süddeutschland
3.470 Beiträge
 
Delphi XE3 Enterprise
 
#5

AW: Simulate infrared film

  Alt 29. Nov 2010, 12:06
as far as i can see the part you marked is ConvertBitmapToGrayscale
if not you can play with theis part of the Code

Delphi-Quellcode:
       for x := 0 to bmp.Width - 1 do
          begin
              pscanLine[x].rgbBlue := 0;
              pscanLine[x].rgbGreen := GetDoubleByte(pscanLine[x].rgbGreen);
          end;
Thomas Wassermann H₂♂
Das Problem steckt meistens zwischen den Ohren
DRY DRY KISS
H₂ (wenn bei meinen Snipplets nichts anderes angegeben ist Lizenz: WTFPL)
  Mit Zitat antworten Zitat
Medium

Registriert seit: 23. Jan 2008
3.679 Beiträge
 
Delphi 2007 Enterprise
 
#6

AW: Simulate infrared film

  Alt 29. Nov 2010, 14:16
What Bummi described first yields very close results to what you showed us. You just made the error not to limit the green channel to 0..255, which causes this "interesting" effect (caused by byte overflow). So don't just take g*2, but min(g*2, 255), and things should look quite similar to what you want.

At least color-wise. The "grain" and "flare" options simply seem to apply some noise and blur, where it could be that the blur is weighed by brightness, which gives a slight "overshot" look.

But to be honest: That doesn't really look much like an IR image, but I didn't expect that either =)
"When one person suffers from a delusion, it is called insanity. When a million people suffer from a delusion, it is called religion." (Richard Dawkins)
  Mit Zitat antworten Zitat
Benutzerbild von Bummi
Bummi

Registriert seit: 15. Jun 2010
Ort: Augsburg Bayern Süddeutschland
3.470 Beiträge
 
Delphi XE3 Enterprise
 
#7

AW: Simulate infrared film

  Alt 29. Nov 2010, 15:11
@Medium

wo findet der Überlauf statt?
Delphi-Quellcode:
Function GetDoubleByte(i:Integer):Byte;
  Begin
    Result := i * 2;
    if Result > 255 then Result := 255;
  End;
Thomas Wassermann H₂♂
Das Problem steckt meistens zwischen den Ohren
DRY DRY KISS
H₂ (wenn bei meinen Snipplets nichts anderes angegeben ist Lizenz: WTFPL)
  Mit Zitat antworten Zitat
Namenloser

Registriert seit: 7. Jun 2006
Ort: Karlsruhe
3.724 Beiträge
 
FreePascal / Lazarus
 
#8

AW: Simulate infrared film

  Alt 29. Nov 2010, 15:24
@Medium

wo findet der Überlauf statt?
Delphi-Quellcode:
Function GetDoubleByte(i:Integer):Byte;
  Begin
    Result := i * 2;
    if Result > 255 then Result := 255;
  End;
Die Prüfung auf >255 bringt hier nichts, weil der Typ des Rückgabewerts Byte ist. D.h. bei der Prüfung hat der Überlauf schon stattgefunden. Wenn dann so:
Delphi-Quellcode:
Function GetDoubleByte(i:Integer):Byte;
var
  tmp: Integer;
  Begin
    tmp := i * 2;
    if tmp > 255 then tmp:= 255;
    Result := tmp;
  End;
Ist aber unnötig umständlich. Da würde ich Mediums Variante mit der min -Funktion (Unit "math") vorziehen.
  Mit Zitat antworten Zitat
Benutzerbild von Bummi
Bummi

Registriert seit: 15. Jun 2010
Ort: Augsburg Bayern Süddeutschland
3.470 Beiträge
 
Delphi XE3 Enterprise
 
#9

AW: Simulate infrared film

  Alt 29. Nov 2010, 15:27
Danke
Thomas Wassermann H₂♂
Das Problem steckt meistens zwischen den Ohren
DRY DRY KISS
H₂ (wenn bei meinen Snipplets nichts anderes angegeben ist Lizenz: WTFPL)
  Mit Zitat antworten Zitat
Benutzerbild von Bummi
Bummi

Registriert seit: 15. Jun 2010
Ort: Augsburg Bayern Süddeutschland
3.470 Beiträge
 
Delphi XE3 Enterprise
 
#10

AW: Simulate infrared film

  Alt 29. Nov 2010, 16:36
another idea for infrared fake
Delphi-Quellcode:
Procedure NightVision(bmp:TBitMap);
begin
   Gamma(bmp,0.3);
   ConvertBitmapToGrayscale(bmp);
   InvertBitMap(bmp);
   Multiply(bmp,0,3.5,0);
end;
Thomas Wassermann H₂♂
Das Problem steckt meistens zwischen den Ohren
DRY DRY KISS
H₂ (wenn bei meinen Snipplets nichts anderes angegeben ist Lizenz: WTFPL)

Geändert von Bummi (12. Okt 2012 um 06:37 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:38 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz