LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading .FIT/.FITS files

Hi.

 

I have to read an image from a FIT file used in astronomy, I use GFITSIO library . and I can only get an image with 50 shades of blue...  ("kai.jpg"  in attachment) .

 
Here is the part of my diagram which reads the FIT file.

 

1) How can I get an image with RGB ? My aim is to get the image " H130000.png" in attachment .

 

2) Do you have an idea about how to flip the image ( up/down )? certainly an operation on the data matrix but I don't succeed . This point is much less important.



Thanks for your answers.

Download All
0 Kudos
Message 1 of 7
(3,955 Views)

If you save your code sample as a Snippet (select on Block Diagram, Edit menu, "Save Selected as Snippet"), you get a .png file, like you attached, but one that we can paste into our own Block Diagram and (through NI "Magic") have it turn into LabVIEW code.  Much easier for us to see and test.

 

If you have your image as a 2D array, the easiest way to flip it is to simply "rebuild" the array -- read it in a row at a time, and build it up, appending the latest row read (which would be the top row of the unread matrix) to the top of the array you are building up.  This would put the first row of your input matrix as the last row of your result matrix, flipping the picture about the horizontal axis.

 

I'm not sure what you want to do with color, but there are lots of IMAQdx and Picture routines that handle RGB.

 

Bob Schor

 

0 Kudos
Message 2 of 7
(3,900 Views)

@bejard wrote:

1) How can I get an image with RGB ? My aim is to get the image " H130000.png" in attachment .


that image seems black&white. Can you explain what you mean by RGB here?


@bejard wrote:

2) Do you have an idea about how to flip the image ( up/down )? certainly an operation on the data matrix but I don't succeed . This point is much less important.


There are many ways to transform a 2D array. Long ago I wrote simple code for all possible transformations. . 😄

 

0 Kudos
Message 3 of 7
(3,892 Views)

Very elegant, Christian.  Just for fun, I coded my "simple, off-the-top-of-my-head" algorithm for a vertical flip and Christian's, and tested it against a 1000 x 1000 array of random Dbls.  One difference between our algorithms is that Christian's is an "in-place" routine, which overwrites the input (and doesn't need to create new Array elements).  I did my flip first, then his, and compared the answers -- they were identical (as they should have been).

 

Mine took 4 seconds.  Christian's took 8 (milliseconds, but come on, what's a few factors of 10 between friends, right?).  Suggests that the Back of the Envelope (or the Top of your Head) is not a good place for elegant and fast algorithms.

 

Bob Schor

Message 4 of 7
(3,876 Views)


I attached the Snippet.

 

Thanks for your explanation Bob_Schor and 

 

 

0 Kudos
Message 5 of 7
(3,845 Views)

Merci beaucoups pour le Snippet.  I downloaded your black-and-white image and wrote the following routine to read it in and display it in normal and "flipped" mode.  I'm not 100% certain that you need to carry all of the unaffected wires across from the Unflatten to the Flatten function, but doing it certainly works.  It is also how I discovered how your image was stored.

 

I suspect that if you inspect the 24-bit bitmap, you'll find RGB channels with identical value in each channel (giving shades of gray).  To learn more about how to "colorize" this, the Vision discussion group might have more "experienced" viewers.  I've done a little with images, and have a colleague who has done more than I, but I'm not a "expert" ...

 

Bob Schor

0 Kudos
Message 6 of 7
(3,820 Views)

Yes but the file "H130000.png" is what I want to get. The source file is a FITS file , I attached it here in zip .

 

So I use the GFITSIO library and after I convert to JPG to use it easier., but shades of blue.

 

As the JPG here is RGB, maybe there is data only on B Channel ?  But stars should be white in this case

 

 

0 Kudos
Message 7 of 7
(3,793 Views)