0

enter image description here

enter image description here

Is there a way to fuse the Jpeg image with the correspondant pixel temperature shown in the stringgrid attached. After the fusion, mouse arround and read the temperatures from the image. If there is, please can anyone show me how.

Thank you, AmmadeuX

Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
Ammadeux
  • 325
  • 1
  • 5
  • 15
  • 1
    It looks like a trivial change of coordinates will do (Y = AX + B). – Andreas Rejbrand Jan 23 '13 at 20:25
  • 3
    I'm quite lost with what you're asking here. You want to get value from that string grid based on which pixel you're pointing on in your image ? You point for instance on pixel with coordinates [1;1] and you'll get value 23.73 based on the table from your screenshot ? – TLama Jan 23 '13 at 22:00
  • The tables I get are from a FLIR software, the brand of my thermal imaging camera. Whennever I take a thermal image I can upload it to this software and get an excel spreadsheet table with the temperature of each pixel. What I'm asking, is it possible to merge/fuse the actual image with the data, as the image is 800x600 and the spreadsheet has that same amount of cells, but in temperature(numeric values) – Ammadeux Jan 24 '13 at 00:27
  • I'm using a Timage, yeah sorry about the buttons. They just say thing like, browse tables, and close. – Ammadeux Jan 24 '13 at 00:29
  • Why do you want to fuse them? Determine the pixel coordinate of where the mouse is on, and read the temperature from the table (not from the image). Jerry's answer's first point should get you started on that. – Sertac Akyuz Jan 24 '13 at 00:35
  • I understood the question being "Take readings of the image by pointing over it with a mouse" – Jerry Dodge Jan 24 '13 at 00:38
  • @Jerry - Apparently! But the poster has some merge of image and temperatures on mind, I've no idea what that *fused thing* would look like. – Sertac Akyuz Jan 24 '13 at 00:43
  • I would need to know the actual table structure, because I doubt the screenshot of the grid above is exactly how it's stored in the database. I also don't understand what the actual content of each cell represents. – Jerry Dodge Jan 24 '13 at 00:44
  • I still think, it's about reading value from string grid based on hovered mouse coordinates. See *...and get an excel spreadsheet table with the temperature of each pixel.* – TLama Jan 24 '13 at 00:44
  • @TLama - See *merge/fuse*. – Sertac Akyuz Jan 24 '13 at 00:45
  • 2
    We are trying to make out what the question is asking, people are posting answers according to their understanding. Meanwhile, I don't see an effort from the poster to make this clear. Voting to close... – Sertac Akyuz Jan 24 '13 at 00:47
  • Agreed, It's a good question potentially, but not enough effort has been put in to making it clear enough for people to help. – Jerry Dodge Jan 24 '13 at 00:49
  • @AdhilMarcosAhmad First, you need to clarify which is your primary source of data, the Image, or the Table. If you have both, which one came first? That one should be the primary. Next, you need to edit your question to make this clear, as well as provide insight to us as to what the data in the table actually represents. Then, you can only hope that your question will not be closed or would be re-opened for a more useful answer. This is how StackOverflow works. – Jerry Dodge Jan 24 '13 at 00:54
  • The image comes first, in a radiometric Jpeg format, and than I can acquire the table correspondant to that image. – Ammadeux Jan 24 '13 at 01:00
  • So after you have an image, you save each pixel of this image into a database, correct? – Jerry Dodge Jan 24 '13 at 01:01
  • Or one more thing to clarify: Is the "Image" coming from a different original source than the "Table" is coming from? This is even more important. At this point, I'm assuming you have an image, and at some point each pixel is recorded into a table of some kind – Jerry Dodge Jan 24 '13 at 01:02
  • I'm just trying to find if there is a way in delphi XE3 to read both this information in a single view, observing the image (with the intensity of each color, colder to hotter) and the correspondant temperature of each pixel. – Ammadeux Jan 24 '13 at 01:03
  • You tagged this question as `Delphi-XE2` but now you mention `XE3`? – Jerry Dodge Jan 24 '13 at 01:03
  • Yes I'm currently doing that with the stringgrid. Jerry Dodge – Ammadeux Jan 24 '13 at 01:04
  • I didn't see a tag for XE3, that's why I tagged XE2, it was the closest version. – Ammadeux Jan 24 '13 at 01:05
  • So in this project of yours, when you load an image, you also get the pixels and copy them over to a string grid? Keep in mind that none of us presumably know about infrared technology (how it works on a technical level), so you need to tell us what the data in that grid actually is. – Jerry Dodge Jan 24 '13 at 01:05
  • Yes there is a tag for XE3, so I just edited your question to replace XE2 with XE3 instead – Jerry Dodge Jan 24 '13 at 01:06
  • The data in the stringgrid is ponctual temperatures, given by the software by combination of color itensity. – Ammadeux Jan 24 '13 at 01:09
  • I'm still not understanding, what are "Ponctual temperatures"? I shouldn't have to research this to help you (as with any question on this site). You should skip the "infrared" aspects of it and jump to the real question. I'm sorry, but I can't help any further until you edit your question to include more specific inquiries. And simply adding a link to something about what you're doing won't work. Each cell has 2 numbers, what do those numbers mean? And we're still assuming that the "Cells" of the "Cols" and "Rows" of this grid are individual pixels from the image. Please make this clear. – Jerry Dodge Jan 24 '13 at 01:20
  • they are not two numbers, the two second numbers are decimal value of the temperature. like the first one: 24.74(almost 25) Degrees celsius. And yes [1,1][Row,Col]=1 Temperature – Ammadeux Jan 24 '13 at 01:29
  • sorry for not clearing this since I stated my question. cell [1,1] is the temperature of the first pixel of the image. – Ammadeux Jan 24 '13 at 01:34
  • The screenshot above appears to have commas in every cell, it doesn't look like decimals. Probably because the pic has been shrunk in size, so it appears distorted. – Jerry Dodge Jan 24 '13 at 02:44
  • Actually, upon zooming in up close, they in fact are commas. This is where that confusion comes in. Surely you meant to put decimals in there? – Jerry Dodge Jan 24 '13 at 02:45
  • 1
    @Jerry, our country e.g. uses comma as a decimal separator. Adhil, then I'm really lost with your question... Since I was bored, [`I've made a project`](http://code.google.com/p/projects-stackoverflow-tlama/downloads/detail?name=14488704.ZIP) (but don't take it seriously since I really have no idea what you want to do), which shows how to read a temperature from image pixels when you hover it. The calibration is made by the color stripe (with height of 95 pixels) on the right side of your example picture and the fact that the temperature range shown in that bar is from 24-37°C. – TLama Jan 24 '13 at 02:58
  • Thanks @TLama for making that clear to me, being 100% American I have never heard of other countries using a comma as a decimal separator. I thought there was an alternate version of StackExchange for other countries? Or I'm just dreaming? – Jerry Dodge Jan 24 '13 at 03:00
  • Welcome to Stack Overflow! The comments are not a good place for long discussions, please move to the chat if you want to continue! – markus Jan 24 '13 at 12:49
  • 2
    @JerryDodge You being 100% american (whatever that means) does not mean you do not have to educate yourself about the world. Indeed america is not the standard for units and such, just think of how the US is still using the pre-historic inches, pounds and whatnot. Commas are indeed used as decimal separator in large parts of the world. – markus Jan 24 '13 at 12:53
  • @markus-tharkun So, that would also mean I should educate myself about all the languages around the world? And how to convert to/from every currency in the world? And how to format the dates in every country? I mean I'm just automatically expected to know this? No, this is not fair that I get criticized for not knowing something this foreign. – Jerry Dodge Jan 24 '13 at 13:37
  • 2
    @JerryDodge: Knowing that [half of the world](http://en.wikipedia.org/wiki/Decimal_comma#Hindu.E2.80.93Arabic_numeral_system) (including my country, Sweden) make use of decimal commas instead of decimal points is pretty basic. Knowing what *each* specific country does, however, is a bit overkill. [After all, I know your language (English) very well. How good are you in Swedish?] – Andreas Rejbrand Jan 24 '13 at 22:12
  • Last comment, as I hate to pollute StackOverflow, but just a point, I just asked everyone in my company, American, Bulgarian, Egyptian, Indian, and Persian, no one has ever heard of using commas as decimals. Not saying you're wrong, but please don't expect everyone to know this. I rest my case. – Jerry Dodge Jan 24 '13 at 22:21

1 Answers1

2

What I understand is that you have three different questions at hand. I will point them out below, along with an answer. But please, you need to do your best to get these types of projects done yourself, and only ask questions here if you have a specific issue which needs to be resolved. It's always subjective to ask "How to do something".

Questions 2 and 3 are either-or solutions, meaning each one could be a different question and answer all-together, completely separate. But they both still depend on the first question.

Question 1: "How do I identify the color of a pixel which the mouse is pointed over?"

I am assuming you're using a standard TImage control with its default properties, and is not set to re-size, stretch, or center the image. If you need to do that, there's a different approach.

First, you have to identify which pixel the mouse is pointed over. There are a few ways of doing this, but depending on what control you are using to display the image (I'm assuming a standard TImage), I would recommend using the Mouse Move event (OnMouseMove) to capture movement of the mouse over this control. At this point, you need to identify the current mouse position. Thankfully, this event comes with the X and Y position of the mouse pointer.

Then, you need to get the canvas of the image. You can get this with:

TImage.Picture.Bitmap.Canvas

Next, read the Canvas' Pixels[] property to get the color.

Question 2: "How do I identify where a color falls on a From/To scale?"

Now that you know what color the mouse is pointed over, you need to identify in which position of your scale this color belongs. For this, it's easiest to stick with only 1 color channel. Your example above illustrates a combination and fade of different colors, which is way too tricky for me to try to explain. Please ask this as an additional question, because it requires its own thought which I cannot do (requires extensive math which I'm not good at).

Question 3: "How do I link an image to a table of data?"

Since you have a table of temperature readings, you need to read this table by column/row based on the individual pixel provided in the first question above.

Since you already know the X/Y position of the mouse, use these same variables to identify the column/row of the grid. (I discourage using a grid as your primary base of storing this data, you should use a client-dataset instead, and dynamically load the grid with that data.)

Conclusion:

Here's the code of a sample app I prepared for you. It should help you understand the basics behind what you're doing. You'll have to pick your own image, as I didn't want to pollute this answer's code with raw image data.

NOTE: Once you edit your question to be clear as to how you expect the image to be linked to the data, then I will modify my answer. Otherwise, this is the best I can explain in its current state.

Unit1.pas

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls, Vcl.ComCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Shape1: TShape;
    StatusBar1: TStatusBar;
    procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Integer);
var
  Color: TColor;
  Canvas: TCanvas;
  R, G, B: Byte;
begin
  Canvas:= Image1.Picture.Bitmap.Canvas;
  Color:= Canvas.Pixels[X, Y];
  Shape1.Brush.Color:= Color;
  R:= GetRValue(Color);
  G:= GetGValue(Color);
  B:= GetBValue(Color);
  StatusBar1.Panels[0].Text:= 'Pos: '+IntToStr(X)+' x '+IntToStr(Y);
  StatusBar1.Panels[1].Text:= 'Clr: '+IntToStr(Color);
  StatusBar1.Panels[2].Text:= 'RGB: '+IntToStr(R)+' x '+IntToStr(G)+' x '+IntToStr(B);
end;

end.

Unit1.dfm

object Form1: TForm1
  Left = 315
  Top = 113
  Caption = 'Form1'
  ClientHeight = 415
  ClientWidth = 548
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  DesignSize = (
    548
    415)
  PixelsPerInch = 96
  TextHeight = 13
  object Image1: TImage
    Left = 0
    Top = 0
    Width = 548
    Height = 281
    Align = alTop
    Anchors = [akLeft, akTop, akRight, akBottom]
    OnClick = Image1Click
    OnMouseMove = Image1MouseMove
  end
  object Label1: TLabel
    Left = 8
    Top = 285
    Width = 31
    Height = 13
    Anchors = [akLeft, akBottom]
    Caption = 'Label1'
  end
  object Shape1: TShape
    Left = 8
    Top = 312
    Width = 532
    Height = 57
    Anchors = [akLeft, akRight, akBottom]
  end
  object StatusBar1: TStatusBar
    Left = 0
    Top = 396
    Width = 548
    Height = 19
    Panels = <
      item
        Width = 150
      end
      item
        Width = 150
      end
      item
        Width = 50
      end>
  end
end
Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
  • Hey Dodge I liked the code you gave me, are the numbers on the Label1 a combination of the RGB(255x255x255), if if that is so. How can I show them separately? like: Red itensity-200, Blue itensity-100, Green itensity-50. – Ammadeux Jan 24 '13 at 01:19
  • Use `GetRValue()`, `GetGValue`, and `GetBValue` to get the individual bytes representing the RGB values. – Jerry Dodge Jan 24 '13 at 02:34
  • Hello Jerry, The modifications were only for the image1mouseover procedure? I'm getting many errors this time. – Ammadeux Jan 24 '13 at 18:16
  • @AdhilMarcosAhmad Did you re-copy the full source of both the unit and dfm file? The only thing that's different is I've added a new control and moved the description from the label to the new status bar, so you can see the separation of info easier. – Jerry Dodge Jan 24 '13 at 18:21
  • Ok, but I still need to load the image to the program. so how can I manage to but a browse button with an openpicturedialog to load the jpeg image to the program? – Ammadeux Jan 24 '13 at 18:33
  • @AdhilMarcosAhmad Please, I'm drawing the line there, I will not continue to help if you keep asking new questions in the comments. It sounds like this project is more than you are able to handle, please take the time to learn Delphi yourself, instead of asking everyone every little thing you need to know. – Jerry Dodge Jan 24 '13 at 18:35
  • I don't understand, here when you declare: type TForm1 = class(TForm) Image1: TImage; Label1: TLabel; Shape1: TShape; and got rid of the label, and got a statusbar, should I declare the status bar? – Ammadeux Jan 24 '13 at 18:50
  • My mistake, I only replaced the procedure, immediately will fix... – Jerry Dodge Jan 24 '13 at 18:59
  • It worked perfectly now, thanks for giving you this much trouble. I studied Delphi, but didn't get in to this "image processing"/ visualization part – Ammadeux Jan 24 '13 at 19:36