Cruisers Forum
 


Reply
  This discussion is proudly sponsored by:
Please support our sponsors and let them know you heard about their products on Cruisers Forums. Advertise Here
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 15-04-2011, 23:53   #76
MdJ
Registered User

Join Date: Jul 2010
Location: France
Boat: Etap 22i
Posts: 65
Re: Raster - Question about the color reduction "Quantize"

Raster - Question about The Color reduction "Quantize" - Part 2

What is the good solution for KAP map ?

The frame or error diffusion method is not good for kap files because the compression in the files is very bad and bad for photo.

The KAP compression note the number of pixels with the same color and dithering produces an image with different colors for each pixels.

Therefore do not use:
  • irfanview reduction method Floyd - Steinberg

You can use :
  • Gimp reduc Index (Histogram)
  • irfanview default
  • imagemacik with dither = None
or, of course, directly imgkap (only if you want )

I tested these methods with same picture and here are the results:

Command line for imagemagick and imgkap (on ubuntu EliteBook 8440p) :
ImageGraphic :
> convert 999502BITS24.png -dither None -colors 128 imagemagick.png
Time : 17s

imgkap
> imgkap 999502BITS24.png 999502.KAP 999502BITS24WR.KAP
Time 1.4s
> imgkap 999502BITS24wR.KAP imgkap.png
Time 0.2s

original.png imagemagick.png irfanview.png gimp.png and imgkap.png
Attached Thumbnails
Click image for larger version

Name:	original.jpg
Views:	372
Size:	387.4 KB
ID:	26209   Click image for larger version

Name:	imagemagick.jpg
Views:	382
Size:	451.1 KB
ID:	26210  

Click image for larger version

Name:	irfanview.jpg
Views:	408
Size:	450.1 KB
ID:	26211   Click image for larger version

Name:	Gimp.jpg
Views:	351
Size:	489.8 KB
ID:	26212  

Click image for larger version

Name:	imgkap.jpg
Views:	444
Size:	503.4 KB
ID:	26213  
MdJ is offline   Reply With Quote
Old 16-04-2011, 07:14   #77
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
Re: imgkap - kap File Converter Tool

Thanks,M'dJ!

You know how it is!!You just want to do something that seems simple,and move on to the next task,but are presented with a panoply of settings that might make or break the project!...Floyd-Steinberg dithering,etc..

It's good to "nail it down" as you are doing!
HappySeagull is offline   Reply With Quote
Old 16-04-2011, 10:20   #78
MdJ
Registered User

Join Date: Jul 2010
Location: France
Boat: Etap 22i
Posts: 65
Re: imgkap - kap File Converter Tool

Last point about KAP file and colors, unless you have questions?

libbsb, tif2bsb only accept TIF files with 8 or 4 bits

An image with 128 colors can be saved to a file in 24 bit (RGB) or 16-bits or 32 bits...

To be accepted by tif2bsb must therefore make a tif file with a maximum of 127 colors and a depth of 8

With imagemagick then you must do:

>convert myfile -colors 127 -depth 8 -dither None myfile.tif

Otherwise the risk is to have a tif file with 127 colors, but in 24-bit (RGB) is random depending on the type of image origin.



Sorry to be a little heavy
or you can use the latest version of imgkap ...
M'dJ
MdJ is offline   Reply With Quote
Old 16-04-2011, 20:06   #79
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
Re: imgkap - kap File Converter Tool

No,no,M'dJ.It's quite interesting.There's been a lot of discussion about this on the "Charts" thread.....and I think you are really onto something new and better in the image conversion process...Plus, Imgkap is very small, and fast and yet does a very good job making a chart.
HappySeagull is offline   Reply With Quote
Old 23-04-2011, 06:53   #80
MdJ
Registered User

Join Date: Jul 2010
Location: France
Boat: Etap 22i
Posts: 65
Re: imgkap - kap File Converter Tool - V1.0B

[QUOTE=MdJ;663072]New release of Imgkap 1.1a.

Intermediate version to handle RGB DSK DAY NGT NGR GRY PRC PRG palette existing in the map from NOAA

Only the C program is provided, to compile it as version 10a
> imgkap.c gcc-O3-s-o-lfreeimage imgkap

It can make images (tif, bmp, png ...) with selectionned palette in KAP file.

The upcoming release will produce a file with at least KAP image NGT (night) and can be DSK (evening). But this option requires more work, analysis of the palette, HSL conversion ...


Description
imgkap1-n ALL file.kap file.tif
Option:-n [RGB | DAY | DSK | NGT | NGR | GRY | PRC | PRG | ALL]
produces an image with the palette requested and present in the KAP file.
Default palette used : RGB

The value ALL ​​gives a multipage image file with the existing palettes in the file KAP.
ALL works only with a TIF or GIF
M'dJ
MdJ is offline   Reply With Quote
Old 23-04-2011, 12:31   #81
MdJ
Registered User

Join Date: Jul 2010
Location: France
Boat: Etap 22i
Posts: 65
Re: imgkap - kap File Converter Tool - V1.0B

Quote:
Originally Posted by MdJ View Post
> imgkap.c gcc-O3-s-o-lfreeimage imgkap
imgkap1-n ALL file.kap file.tif
Option:-n [RGB | DAY | DSK | NGT | NGR | GRY | PRC | PRG | ALL]
Many error in my last message, i can be an ass...

to compile
> gcc imgkap.c -O3 -s -l freeimage imgkap.c imgkap

option :
not -n : -p

> imgkap1 -p ALL file.kap file.tif

Option:-p [RGB | DAY | DSK | NGT | NGR | GRY | PRC | PRG | ALL]
MdJ is offline   Reply With Quote
Old 29-04-2011, 09:40   #82
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
Re: imgkap - kap File Converter Tool

M'dJ...
from the Charts thread,I thought you'd be interested in this...

Nobletec 4.1 (1998!) loading charts..
Here,see the two 379501 charts...the EX is an imgkap.Looks GOOD!
"Open link in new tab" works best for me,to view images-you get the zoom then.

Click image for larger version

Name:	NobletecSeesKAPSas_1.jpg
Views:	452
Size:	228.1 KB
ID:	26736


Now,here's some more.You can see the odd ones,eh?Also imgkap

Click image for larger version

Name:	NobletecSeesKAPSas_2.jpg
Views:	359
Size:	235.1 KB
ID:	26737

The difference is in the kap headers,I think.

Here's 379501EX which is "pretty" in the load dialogue...GOOD ONE!

! 2011 imgkap 1.0b file generator by M'dJ at 29/04/2011 from 379501EX_16colours.tif
!Copyright 1996, NDI. All Rights Reserved
!ColourEditBySeagull
BSB/NA=COLOURED LANGLEY PASSAGE ESTEVAN GROUP,NU=3795,RA=10386,5586,DU=254
KNP/SC=12000,GD=NAD 27,PR=POLYCONIC
PP=-129.6628, PI= 0.50000,SP=UNKNOWN,7 SK= 0.00
UN=FATHOMS,SD=LNT,DX= 1.20,DY= 1.20
CED/SE=3795,RE=379501,ED=29/04/2011
VER/1.1
OST/1
REF/1,279,5281,53.0290583,-129.7532167


And here's an "ugly" from the second picture ....BUT it does LOAD and works fine.

! 2011 imgkap 1.0b file generator by M'dJ
! Map generated not for navigation created at 12/04/2011
! Extend widthin 768 heightin 768 to widthout 770 heightout 768
! Size in milles 76.61 x 76.60
! Resolution units METERS - 184.25x184.72 -> 1847217 at 254 dpi
VER/3.0
OST/1
CED/SE=1,RE=1,ED=12/04/2011
BSB/NA=
NU=UNKNOWN,RA=770,768,DU=254
KNP/SC=1847217,GD=WGS 84,PR=MERCATOR,PP=0.00
PI=UNKNOWN,SP=UNKNOWN,SK=0.0,TA=90
UN=METERS,SD=UNKNOWN,DX=184.25,DY=184.72
REF/1,0,0,53.330873,-130.078125

unfortunately,I can't be sure if this is helpful because the forum can screw up spacing and stuff....
HappySeagull is offline   Reply With Quote
Old 29-04-2011, 11:32   #83
Registered User

Join Date: Sep 2009
Location: Rome
Posts: 320
Re: imgkap - kap File Converter Tool

Hello,

as far as I know, the length of a single BSB text row shall not exceed 80 chars.

Try to delete (or shorten) only the first row:

! 2011 imgkap 1.0b file generator by M'dJ at 29/04/2011 from 379501EX_16colours.tif

and try again.

Ciao, Marco.
GPS-Marco is offline   Reply With Quote
Old 29-04-2011, 14:34   #84
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
Re: imgkap - kap File Converter Tool

Quote:
Originally Posted by GPS-Marco View Post
Hello,

as far as I know, the length of a single BSB text row shall not exceed 80 chars.

Try to delete (or shorten) only the first row:

! 2011 imgkap 1.0b file generator by M'dJ at 29/04/2011 from 379501EX_16colours.tif

and try again.

Ciao, Marco.
GPSMarco,...but THAT one(379501EX_16.kap) looks fine in the VisNav dialogue!
(It's in the upper picture)
HappySeagull is offline   Reply With Quote
Old 29-04-2011, 15:23   #85
MdJ
Registered User

Join Date: Jul 2010
Location: France
Boat: Etap 22i
Posts: 65
Re: imgkap - kap File Converter Tool

Quote:
Originally Posted by GPS-Marco View Post
Hello,

as far as I know, the length of a single BSB text row shall not exceed 80 chars.
You're right
I change this to the next version.

Thank's
MdJ is offline   Reply With Quote
Old 29-04-2011, 17:36   #86
Registered User
 
HamishB's Avatar

Join Date: Jan 2010
Location: New Zealand
Posts: 286
Re: imgkap - kap File Converter Tool

Quote:
Originally Posted by HappySeagull View Post
unfortunately,I can't be sure if this is helpful because the forum can screw up spacing and stuff....
put it inside [ code ]formatted text here[ /code ], but without the extra spaces around the word "code". then it will show verbatim.

Hamish
HamishB is offline   Reply With Quote
Old 29-04-2011, 19:51   #87
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
Re: imgkap - kap File Converter Tool

Righto,Hamish!Thanks!I wondered how you do that...Need to study the Forum help pages.You'll see me do this next time!
HappySeagull is offline   Reply With Quote
Old 14-05-2011, 02:54   #88
MdJ
Registered User

Join Date: Jul 2010
Location: France
Boat: Etap 22i
Posts: 65
imgkap - kap File Converter Tool V1.1

imgkap Version 1.1

Install
For all system, tested on Windows 32 and on linux 32 and 64 bit
Having a C or C++ compiler : gcc, g++…

Download and install freeimage-dev, on Ubuntu > sudo apt-get install libfreeimage-dev
Prefer last version, see The FreeImage Project

Download imgkap.c and compile width gcc or g++:
> gcc imgkap.c -O3 -s -lfreeimage -o imgkap
For Windows :
Use imgkap.exe include all code, requires no download FreeImage.
Download imgkap.1.doc to imgkap.4.doc
MS DOS > copy /b imgkap.*.doc imgkap.zip
and unzip 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.
Command line : imgkap [options] [inputfile] [lat0 lon0 lat1 lon1 | headerfile] [outputfile]
options can be anywhere in the command line
This software can :
convert map KAP file to image file
convert image file to KAP file
using WGS84 coordinates of the image
using data and coordinates from KAP file or header
convert KML file to KAP file
convert KAP file to KAP file
used to change colors DSK and NGT
extract header (text) KAP file
File extension :
Input KAP : Can be KAP or N01
Header file format : TXT or KAP
Image formats accepted are the formats accepted by FreeImage : bmp,gif,jpg or jpeg,pbm,pgm,png,ppm,tga,tif or tiff…
KML imput : GroundOverlay kml file with image file.
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
different format are accepted : -1.22 1°10'20.123N -1d22.123 ...
Options :
-f : fix units to FATHOMS
-s name : fix souding datum
-t title : change name of map
-p color : color of map
Kap to image
color : ALL|RGB|DAY|DSK|NGT|NGR|GRY|PRC|PRG
ALL generate multipage image, use only with GIF or TIF

Image or Kap to Kap
color : NONE|KAP|MAP|IMG
NONE use colors in image file, default

KAP only width KAP or header file, use color tag in KAP file

MAP generate DSK and NGB colors for map scan

(< 64 colors, Black -> Gray, White -> Black)

IMG generate DSK and NGB colors for image (photo, satellite...)

Description :

Convert kap to image or extract header :
imgkap mykap.kap myimg.png
convert mykap.kap to myimg.png
• imgkap mykap.kap myheader.txt myimg.png
convert mykap.kap to myimg.png and extract myheader.txt
header not contain IFM and OST tag
• imgkap mykap.kap mheader.txt
extract myheader.txt
header not contain IFM and OST tag
• imgkap mykap.kap -p NGT myimg.png
convert mykap.kap to myimg.png using NGT palette in KAP file
• imgkap mykap.kap -p ALL myimg.gif
convert mykap.kap to myimg.gif multipage
using all palette in KAP file (DSK, NGT...)
Convert kap to kap :
imgkap mykap.kap -p MAP result.kap
Create result.kap width DAY, DSK and NGT colors.
Useful for old KAP (French SHOM MAP) used in OpenCPN
• imgkap mykap.kap -p NONE result.kap
Create result.kap width only RGB colors.
• imgkap mykap.kap result.kap
not very useful, mykap is converted to internal image
and image is converted to result kap file
Can be tested if original kap have compression problems.
Convert image to kap :

(imgkap include reducing colors to 128 colors)

Convert image file to KAP file using header or kap file
imgkap myimg.png myheaderkap.txt
convert myimg.png into myimg.kap using myheader.txt
colors in KAP are only RGB from image file
• imgkap myimg.png mykap.kap
convert myimg.png into myimg.kap using mykap.kap
• imgkap myimg.png -p KAP myheaderkap.txt
convert myimg.png into myimg.kap using myheader.txt
colors in KAP are colors in myheaderkap
• imgkap myimg.png -p MAP myheaderkap.txt
convert myimg.png into myimg.kap using myheader.txt
colors in KAP are colors in myimg witdh calculated DSK and NGT colors for MAP
• imgkap myimg.png -p IMG myheaderkap.txt
convert myimg.png into myimg.kap using myheader.txt
colors in KAP are colors in myimg witdh calculated DSK and NGT colors for photo or satellite image
Convert KML file to KAP file using header file
imgkap mykml.kml -f -p IMG
convert GroundOverlay mykml file into kap file using name and directory of image , KAP contain DSK and NGT calculated colors
• imgkap mykml.kml mykap.kap
convert GroundOverlay mykml into mykap file
Convert image file to KAP file using WGS84 positioning
imgkap mykap.png 47°87' -3°86' 45°82' -0°70' myresult.kap
convert myimg.png into myresult.kap using WGS84 positioning
• imgkap -s 'LOWEST LOW WATER' myimg.png 47°87' -3°86' 45°82' -0°70' -f -p IMG
convert myimg.png into myimg.kap using WGS84 positioning and options
To modify many informations in kap file :

  1. convert mykap.kap to myimg.png and extract myheader.txt
    imgkap mykap.kap myheader.txt myimg.png
  2. Modify with text editor myheader.txt (colors, REF, PLY...)
  3. convert myimg.png to mykap.kap width myheader.txt using KAP colors
    imgkap myimg.png -p KAP myheaderkap.txt
Care : Resulting colors order is changed, if you want to edit the final kap you must repeat all steps with the last file.
if myimg.png is changed, the KAP colors will not match, then use another option -p MAP or -p NONE or make sure the colors of the image correspond to colors KAP
M'dJ ()
MdJ is offline   Reply With Quote
Old 14-05-2011, 03:36   #89
Registered User
 
sailorF54's Avatar

Join Date: Dec 2009
Location: Perros-Guirec, France
Boat: Jeanneau Sunshine 36
Posts: 999
Re: imgkap - kap File Converter Tool

NOT
MS DOS > copy /b imgkap.*.doc imgkap.zip

but
MS DOS > copy /b imgkap*.doc imgkap.zip

Or dowload here
http://dl.free.fr/f3PSLPVup
sailorF54 is offline   Reply With Quote
Old 14-05-2011, 06:55   #90
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
Re: imgkap - kap File Converter Tool

M'dJ,Merci Beacoup!

SailorF54,tres bon!Merci!for the link

for other execrable linguists like me,the download link is called:
"Telecharger ce fichier".
HappySeagull is offline   Reply With Quote
Reply

Tags
imgkap


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Development Debugging Environment - Setup Help rgleason OpenCPN 654 04-10-2020 05:37
OpenCPN Beta Version 3.1.814 Released bdbcat OpenCPN 185 14-09-2012 07:43
Route File Transfer via SDcard to Garmin 441s four winds Navigation 11 25-02-2012 08:34
GRIB Weather Mark Ward OpenCPN 26 12-02-2012 21:33
Route Properties, Missing Functions James Baines OpenCPN 13 13-07-2011 04:31

Advertise Here


All times are GMT -7. The time now is 05:49.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.