ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder
ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 GIS TIFF Elevation File - Pixel Level Access

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Size 
UserName:
Password:
Mode 
Format  BoldItalicizedUnderline Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailBrowse for an image to attach to your post Browse for a zip to attach to your post Insert CodeInsert QuoteInsert List
   
Message 

 

Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
HMArnold Posted - Oct 10 2019 : 11:27:03
I'm using GIS Elevation raster files in TIFF format, and am trying to access the individual pixel values.

Using ImageEn version 8.7.0

I'm attaching what one looks like when loaded into ArcMap, but the forum server won't allow me to attach an example TIFF file of 7mb.

As I understand, it is essentially a black and white image with the values for each pixel being the elevation of the ground at that spot. Since this area is along the coast, the values in the file I'm working with are between 17 and 59 meters.

Using a normal image viewer, the TIFF looks white, I assume because of the small values.

Once loaded using ImageEN, the "Bitmap.PixelFormat" comes back as "pf24bit".

The only 24 bit pixel access I see is "IEBitmap.ie24RGB[x,y]" that returns a "TRGB" value.

When I use this to read into the array, all values come back as 255 for Red, Green, and Blue.

I've also tried reading the 16 bit word values, but those all come back as the maximum, 65536

Has anyone been able to open one of these GIS TIFF files in ImageEn and access individual pixels? It would be a powerful tool.

Suggestions appreciated



Insert Image:

HM Arnold
10   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Nov 02 2019 : 20:00:21
Thanks, in next week's release, we'll have a further tweak to improve handling of these kinds of images.

Nigel
Xequte Software
www.imageen.com
HMArnold Posted - Oct 31 2019 : 11:32:18
Sorry for the delay

I've uploaded another from the same area but cut from a different source

Thanks for looking at this


attach/HMArnold/20191031113055_CP66SWV2Small1.zip
3185.46 KB

HM Arnold
xequte Posted - Oct 15 2019 : 16:45:08
Hi

We have a fix for this (there are out of range values in this image). Can you supply us some other images for testing?

Nigel
Xequte Software
www.imageen.com
HMArnold Posted - Oct 12 2019 : 08:47:24
Thanks

This file format is pretty much the standard for GIS elevation files. The ability to programmatically read and modify these files at the pixel level would have uses in flood and river analysis, agriculture, and environmental applications.

Somehow embedded in the sample file, besides the elevation values, are two other pieces of information, being the spatial datum and a description of how the pixel dimensions relate to the real world.

Recovery of these values would be nice, but not critical.

Its common for this type of file to be included with a "TFW" or "World File", which is a text file that gives all the required numeric values.

Let me know if I can do anything to assist

And thanks again for looking at this

HM Arnold
xequte Posted - Oct 11 2019 : 22:39:52
Hmm, looks like we don't support that type of TIFF after all. We will investigate further...

Nigel
Xequte Software
www.imageen.com
HMArnold Posted - Oct 11 2019 : 11:38:45
Nigel,

Again, thanks

With everything else taken out, this code fails with the attached floating point error


procedure TForm1.ScanButtonClick(Sender: TObject);
begin
  Image.IO.NativePixelFormat := True; // Use the original pixel format
  Image.IO.LoadFromFileTIFF(ImagePath);
end;





HM Arnold
xequte Posted - Oct 10 2019 : 19:43:16
Hi

In your code above, you call:

PixelFormat := Image.Bitmap.PixelFormat;

I.e. you are activating the the TBitmap of ImageEnView (setting location to ieTBitmap).

Never use the Bitmap property of TImageEnView (it's for legacy code).

Instead use Image.IEBitmap.PixelFormat:

https://www.imageen.com/help/ImageEn/TIEBitmap.PixelFormat.html



Nigel
Xequte Software
www.imageen.com
HMArnold Posted - Oct 10 2019 : 19:22:52
It did allow me to attach it as a zip file

Any suggestions appreciated

attach/HMArnold/20191010192127_Sample.zip
1011.54 KB

HM Arnold
HMArnold Posted - Oct 10 2019 : 19:04:26
Nigel,

Thanks very much

I saw that in some of the other forum posts, and tried it, but get the attached message...

I have also tried it with the LegacyBitmap on and off - with and without the NativePixelFormat

Here is the code..


procedure TForm1.ScanButtonClick(Sender: TObject);
var x, y        : integer;
    PixelFormat : TPixelFormat;
    RGB         : TRGB;
    Value       : word;
begin
  (*Image.LegacyBitmap := false; *)
  Image.IO.NativePixelFormat := true;
  Image.IO.LoadFromFileTIFF(ImagePath);
  ListBox1.Items.Add('Size : '+IntToStr(Image.IEBitmap.Width)+'/'+IntToStr(Image.IEBitmap.Height));
  PixelFormat := Image.Bitmap.PixelFormat;
  case PixelFormat of
    pfDevice  : ListBox1.Items.Add('Pixel Format : pfDevice');
    pf1bit    : ListBox1.Items.Add('Pixel Format : pf1bit');
    pf4bit    : ListBox1.Items.Add('Pixel Format : pf4bit');
    pf8bit    : ListBox1.Items.Add('Pixel Format : pf8bit');
    pf15bit   : ListBox1.Items.Add('Pixel Format : pf15bit');
    pf16bit   : ListBox1.Items.Add('Pixel Format : pf16bit');
    pf24bit   : ListBox1.Items.Add('Pixel Format : pf24bit');
    pf32bit   : ListBox1.Items.Add('Pixel Format : pf32bit');
    pfCustom  : ListBox1.Items.Add('Pixel Format : pfCustom');
  end;
  for x := 500 to 600 do
    for y := 500 to 600 do
      begin
        RGB := Image.IEBitmap.Pixels_ie24RGB[x,y];
        ListBox1.Items.Add('RGB : '+CxIn(RGB.r,4)+' '+CxIn(RGB.G,4)+' '+CxIn(RGB.b,2));
      end;
end;





HM Arnold
xequte Posted - Oct 10 2019 : 18:28:32
Hi

Please set NativePixelFormat to true

https://www.imageen.com/help/ImageEn/TImageEnIO.NativePixelFormat.html

Then you can access the true pixel value, using the appropriate Pixels_ie* property for that PixelType

Nigel
Xequte Software
www.imageen.com