 |
|
11-03-2011, 06:21
|
#1
|
Registered User
Join Date: Jul 2010
Location: France
Boat: Etap 22i
Posts: 65
|
Imgkap - kap File Converter Tool
Hello,
Excuse me (HappySeagull) for putting a little time for this new version.
imgkap program propose to convert image file from/to KAP file, it replaces tiff2kap that converts tiff file to KAP file using WGS84 coordinates.
Imgkap use the opensource FreeImage, it replace tiff2kap and in more integer bsb2tif, bsb2ppm, bsb2png, andtif2bsb ppm2bsb (not bsbfix) which are the standard tools sourceforge, however no more corrected since 2004.
imgkap is optimized for speed: It includes reduction of color (128 colors max in a KAP file)
If necessary, corrects the projection for satellite images (google map ...) or enlarges the size of images to form the map KAP.
This version is an alpha version, it may still be some bugs or errors.
imgkap Version 1.0a
Install
For linux (64 and 32 bit)
Having a C or C++ compiler : gcc, g++…
Download and install freeimage-dev
Ubuntu > sudo apt-get install libfreeimage-dev
(Prefer 3.15 version, see The FreeImage Project)
Download imgkap.c and compile width gcc ou g++:
> gcc imgkap.c -O3 -s -lfreeimage -o imgkap
For Windows
The Windows executable can now be downloaded directly at http://www.dacust.com/inlandwaters/imgkap/Use imgkap.exe include all code, requires no download FreeImage.
Download imgkap1.doc to imgka4.doc
On MS-DOS execute command :
> copy /b imgkap1.doc+imgkap2.doc+imgkap3.doc+imgkap4.doc imgkap.zip
Uncompress imgkap.zip
Optional : You can link this program into another program and use kap conversion function
> gcc myprogram.c -D LIBIMGKAP imgkap.c -lfreeimage -o myprogram
Contact me for more information.
Possible evolution : Using another header format for input and/or output (kml, map…) and other format Geotiff...
Usage
This software can : convert map file KAP to image file
convert image file to ma file KAP
using WGS84 coordinates of the image
using data and coordinates from KAP file
Description of file extension {ext1} map file format, KAP or N01
{ext2} image formats accepted are the formats accepted by FreeImage :
bmp,gif,jpg ou jpeg,pbm,pgm,png,ppm,tga,tif ou tiff…
{ext3} Header file format, text only KAP file
Convert kap to image : • imgkap mykap.kap myimg.png : convert mykap into myimg.png
• imgkap mykap.kap mheader.kap myimg.png : convert mykap into header myheader (only text header kap file) and myimg.png
Description : imgkap maykap.{ext1} [myhader.kap] [myimage.{ext2}] myheader : Is optionnal output file with text only KAP header
myimage : Is optionnal output image file
Note : myheader or/and myimage must be defined. Convert image to kap :
Convert image file to kap file using header file • imgkap myimg.png myheaderkap.kap : convert myimg.png into myimg.kap using myheader.kap for kap informations
• imgkap myimg.png myheaderkap.kap myresult.kap : convert myimg.png into myresult.kap using myheader.kap for kap informations
Description : imgkap myimg.{ext2} myheader.kap [myresult.kap]
myheader can be kap file or text only kap file (headerfile)
if myresult is not defined, directory and name of output kap file is myimg.kap Options : -n : using Neural to reduce number of colors default : Wu color (freeimage).
Note :This conversion option is much slower but better Convert image file to kap file using WGS84 positioning • imgkap mykap.png lat0 lon0 lat1 lon2 myresult.kap : convert myimg.png into myresult.kap using WGS84 positioning
• imgkap -s 'LOWEST LOW WATER' myimg.png lat0 lon0 lat1 lon2 -f : convert myimg.png into myimg.kap using WGS84 positioning and options Description : WGS84 positioning :
lat0 lon0 is a left,top point
lat1 lon1 is a right,bottom point
lat to be beetwen -85 and +85 degree
lon to be beetwen -180 and +180 degree Options : -f : fix units to FATHOMS, default : METERS
-s name : fix souding datum, default : UNKNOWN
-n : using Neural to reduce number of colors default : Wu color (freeimage).
Note :This conversion option is much slower but better Sample : imgkap.exe -f bretagnesud.tiff 47.872144 -3.867188 45.828799 -0.878906 bretagnesudfR.kap
M'dJ
|
|
|
11-03-2011, 08:09
|
#2
|
Registered User
Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
|
Re: imgkap - kap File Converter Tool
Wow!You have been Busy,Mdj!
I am going to try em all tout suite!
|
|
|
11-03-2011, 13:07
|
#3
|
Registered User
Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
|
Re: imgkap - kap File Converter Tool
Wow.Works great!  here's a picture of usage ...
NO EXTRA STUFF!... by the way,there's an app I found to convert degree+minutes to decimal degrees simply.."GPS_sway".The new chart is seen in Kapview.
|
|
|
11-03-2011, 13:39
|
#4
|
Registered User
Join Date: Jul 2010
Location: France
Boat: Etap 22i
Posts: 65
|
Re: imgkap - kap File Converter Tool
Quote:
Originally Posted by HappySeagull
NO EXTRA STUFF!... by the way,there's an app I found to convert degree+minutes to decimal degrees simply.."GPS_sway".The new chart is seen in Kapview.
|
If this sounds interesting, I can add the conversion to degrees+minutes and many formats.
|
|
|
12-03-2011, 09:25
|
#5
|
Registered User
Join Date: Dec 2005
Location: Helsingborg
Boat: Dufour 35
Posts: 3,891
|
Re: imgkap - kap File Converter Tool
MdJ
Thank you for your new program.
I did a conversion using both tiff2bsb and imgkap.
In the resulting kap from imgkap all white areas were black.
The chart has only 13 RGB values while the kap produced by tif2bsb has 15.See the attached file.
Thomas
headers.txt.doc
|
|
|
12-03-2011, 09:49
|
#6
|
Registered User
Join Date: Jul 2010
Location: France
Boat: Etap 22i
Posts: 65
|
Re: imgkap - kap File Converter Tool
Please can you send me B112.png file or your kap file ?
my mail is alain.cousinie@laposte.net
I did many tests, but bugs are possible
In imgkap when generating kap, the colors are sorted and only those used are noted. So it may be normal for the number of colors is smaller.
M'dJ
|
|
|
12-03-2011, 09:55
|
#7
|
Registered User
Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
|
Re: imgkap - kap File Converter Tool
I've also seen a small bug that might be related.
I've had a few that were odd...in the colour conversion.... 
this made from a 256 colour png
some googleearth 16million colour ones also do not interpret well
But,if I re-colour these myself to 16(from 256) and to 128 (from 16million) in Irfanview they work fine as kaps and the colour is correct.
But this app has many merits,Mdj!....for instance,the automatic scaling is a great idea and seems especially suitable for downloaded images where the scale has not been noted or might entail some guessing from the user...
...Isee you are online!I will send you some pngs and the corner fixes I am using...
|
|
|
12-03-2011, 10:19
|
#8
|
Registered User
Join Date: Mar 2010
Location: Canada
Boat: On the Hard
Posts: 336
|
Re: imgkap - kap File Converter Tool
Nubie alert..
Ok on linux.....say I have a screen grab from google of a particular harbour and want to convert that to a kap file to load into OCPN. I need to generate a header file to deal with the needed information.
How do I go about generating such a file, and what is the information contained in the header file. I would assume it would hold both graphical info as well as locational info and datum data, but just guessing.
Once I get past this I could write a simple howto if needed.
Best regards and thanks
/ch
|
|
|
12-03-2011, 11:37
|
#9
|
Registered User
Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,295
|
Re: imgkap - kap File Converter Tool
|
|
|
12-03-2011, 12:08
|
#10
|
Registered User
Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
|
Re: imgkap - kap File Converter Tool
Quote:
Originally Posted by sailias
Nubie alert..
Ok on linux.....say I have a screen grab from google of a particular harbour and want to convert that to a kap file to load into OCPN. I need to generate a header file to deal with the needed information.
How do I go about generating such a file, and what is the information contained in the header file. I would assume it would hold both graphical info as well as locational info and datum data, but just guessing.
Once I get past this I could write a simple howto if needed.
Best regards and thanks
/ch
|
sailias,
I'm a windozer but is there an analogy in linux?
The easiest way is to note the upper left and lower right corners' positions in googleearth before making the screen grab...just push the cursor into the corners until the lat and long don't change.
An important tip is to change the options in Google Earth(if you have it?) to "Decimal Degrees" otherwise you can use a calculator or what linux can do?
when you haved saved the screengrab,make a special textfile for these to copy and paste directly into a cmd window that is "opening" in the same folder that you have imgkap and the screengrab in....
...mine is like this...
imgkap -s MSL -n "Blaircreich 16.png" 56.70149 -4.4989014 56.6562383 -4.3890596
"
sorry,the word wrap is screwing it up.Turn wordwrap off in the text file by the way.Anyways,I just copy and paste the line into the command window.
Use the "imgkap -s MSL -n" as a template line for other grabs.The "-s MSL" is just my choice for MeanSeaLevel,but all this is in Mdj's original post.You can just delete that bit.
I find I can copy and paste several lines at once and get kaps for em!
If the screen grabs are 24b(16 million colour) imgkap will churn away for a while so be patient!Wait for the cmd line to return to the">" or whatever it is in linux?
If imgkap says the image is the wrong size,you did it wrong!
I hope this helps.
|
|
|
12-03-2011, 12:24
|
#11
|
Registered User
Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
|
Re: imgkap - kap File Converter Tool
Quote:
Originally Posted by MdJ
If this sounds interesting, I can add the conversion to degrees+minutes and many formats.
|
...actually,that's seeming like a good idea!
It's always needing remembering and explaining to get all "set up" for imgkap in decimal degrees....I bet that's true of many out there.There are lots of workarounds for all the various approaches to kap-making,but it'd be sooo simple to just input what's there without puzzling.At least to say degrees and decimal minutes,the most common?(ie: 49 45.777 is more "accessible" than 49.76295)
...The reason is that I'm used to the Mercator handiness of a minute=a mile and I guess the Yanks are pretty much fixed in feet,knots and miles too.
|
|
|
12-03-2011, 19:43
|
#12
|
Registered User
Join Date: Mar 2010
Location: Ft. Pierce, FL - Bislig, Philippines - Gladstone QLD
Boat: 1968 Alberg 30 #329
Posts: 451
|
Re: imgkap - kap File Converter Tool
This is a great tool! I find it especially useful to create kaps from the 3600x2400 pixel images available at the "Exploring Google Maps for FSX" site.
Thanks for sharing!
|
|
|
13-03-2011, 07:42
|
#13
|
Registered User
Join Date: Mar 2010
Location: Canada
Boat: On the Hard
Posts: 336
|
Re: imgkap - kap File Converter Tool
Quote:
Originally Posted by nohal
|
Like all typical nubie mistakes, not reading the howto... 
Thanks for pointing out the reference. My appreciated.
/ch
|
|
|
13-03-2011, 10:34
|
#14
|
Registered User
Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
|
Re: imgkap - kap File Converter Tool reconverting!
h,I see! per my green chart,I could fix it myself (my earlier post
http://www.cruisersforum.com/forums/...tml#post641032
Say I want to get the image and the header for instant image editing and "re-kapping"....here's the cmd
imgkap "Googlescotland7 10.kap" "GSgreenheader.kap" "Googlescotlandgreen.tif"
Then to put it back together,after fixing the problem,or doing anything to the image (EXCEPT changing it's size!)
imgkap "Googlescotlandfixed.tif" "GSgreenheader.kap" "GoogleScotlandfixed.kap"
Here's what I noticed in the process..
Do not change the name of the input kap.because the original is written into the header.
Do not edit the header in a simple editor like notepad.uh-uh!Nogo.Well,that's ok.
But,whatever output name you give the new kap,this old original is retained It's still in the header of the new kap....see?here's part of the new chart's header
=1,ED=12/03/2011..BSB/NA=KAP Googlescotland7 10 AT 12/03/2011.. NU=UNKNOWN,RA
Mdj,is there a way to give the edited a REALLY new name?or did I do something wrong?
|
|
|
13-03-2011, 11:19
|
#15
|
Registered User
Join Date: Jul 2010
Location: France
Boat: Etap 22i
Posts: 65
|
Re: imgkap - kap File Converter Tool reconverting!
Quote:
Originally Posted by HappySeagull
imgkap "Googlescotland7 10.kap" "GSgreenheader.kap" "Googlescotlandgreen.tif"
Then to put it back together,after fixing the problem,or doing anything to the image (EXCEPT changing it's size!)
imgkap "Googlescotlandfixed.tif" "GSgreenheader.kap" "GoogleScotlandfixed.kap"
=1,ED=12/03/2011..BSB/NA=KAP Googlescotland7 10 AT 12/03/2011.. NU=UNKNOWN,RA
|
You can change with text editor, ED and NA in GSgreenheader.kap not in KAP file resulting.
I work on color problem now.
Bug is in FreeImage in WU Quantinze, neural is OK but is very long.
M'dJ
|
|
|
 |
|
Thread Tools |
Search this Thread |
|
|
Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
Advertise Here
Recent Discussions |
|
|
|
|
|
|
|
|
|
|
|
|
Vendor Spotlight |
|
|