Cruisers Forum
 


Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 29-01-2011, 17:01   #1
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
Revisiting Tiff2Kap

Heres a handy tool to create kap files-tiff2kap by M'dJ.It was posted earlier HERE http://www.cruisersforum.com/forums/...kap-43352.html but I think it got lost in the shuffle.I revisited and think others might want to try?It doesn't need anything you don't likely have already on a windows machine.

You do need to use the Cmd prompt ONCE.So no s p a c e s in names or data (and F3 key as usual is my friend per typos)

But
All it needs are two diagonal corner-positions in decimal degrees on a maximum 128-colour tif to QUICKLY bake a Mercator kap file readable in everything I've got-even (old)VisNav 4.

There's a multitude of hands-on methods I've used in combo with Google earth screen capture ,Ozi map files and Mobile Atlas Creator, MapCal_2 etc.These will want their images converted to tifs but gleaning the corners is easy when they are told to report as decimal degrees...Make note of corner positions if doing a simple screengrab.

first ,just type
tiff2kap
and it says what it wants.

an example total all up producer Command is:

tiff2kap image.tif 40.0021 -102.0031 39.2342 -101.4562

hit<Enter>
...and image.kap appears very quickly.99% of the time they are keepers.Note negative signs are west Long.

That's it.The number of decimal places seems neither here nor there.I mean 20 works as well as 20.00000 negative signs for West Longitude.
South Lat would also be negative.


As an aside,I find a way to make a "cottage kap"....make a blank tif in a paint program,ascribe positions to the two diagonal corners and then load it with desired corners.Now,tiff2kap tells you what's wrong with image size per corners.so resize the image and reload.A kap is born!Now,draw and paste and mark up the original tiff in happy colours.reload.Voila you can sail around in it or pass it around
"Harbour entrance in fog looks like this from Here!avoid wreck seen there."

Yes,very similar to VisNav, oziExplorer, among others except it's an Almighty kap file.Keep the tif handy and add to it...and rebake as required.. maybe use this as a layer in more sophisticated ways...ie:extract tif with bsb2tiff (from that wonderful multidriver"libbsb-0.0.7"),re-edit image and bake as a special kap to confound your enemies!(Did I say that?Yikes- a joke.)


CLUE for arbitrary image blank?Not so arbitrary.width/height =cos middle lat.Example: height of 3000 pixels wants a width of 2729 where corners are lat 30 and lat 20 ... 2729/3000=cos 24.54 this stinks of spherical trig to me so without the calculator it's easier to blunder once and tiff2kap will tell me how to resize.

BUT if tiff2kap says this when you are CONVERTING something to a kap,it's because you mistyped the corners.
Very handy little tool.
very cool,M'dJ!
HappySeagull is offline   Reply With Quote
Old 30-01-2011, 02:51   #2
Registered User

Join Date: Dec 2005
Location: Helsingborg
Boat: Dufour 35
Posts: 3,891
Tiff2kap has, unfortunately, a few assumptions hard-coded into it.
A normal chart picture with a white "rim" around it will not work. The original picture is assumed to be 1 pixel larger than the outline of the chart proper. The upper left corner is hard coded to (1,1).
This also, like ozi explorer .map charts, makes it impossible to adjust the the outline of the charts, or add more "PLY" points, without manually editing the produced kap file.
The program also assumes that 4 REF points is enough, often it is, but not always.
Code:
   fprintf(out,"KNP/SC=%0.f,GD=WGS 84,PR=MERCATOR,PP=%.2f\r\n", scale,0.0);
    fputs("    PI=UNKNOWN,SP=UNKNOWN,SK=0.0,TA=90\r\n", out);
    fprintf(out,"    UN=METERS,SD=LOWEST LOW WATER,DX=%.2f,DY=%.2f\r\n", dx,dy);
The code assumes that all charts are Mercator charts in WGS 84, that they are metric a that soundings are based on Lowest Low Water.

There are way to many assumptions like those above to make tiff2kap a serious replacement for libbsb.
Perhaps the author of the program can continue the development......

Thomas
cagney is offline   Reply With Quote
Old 30-01-2011, 05:12   #3
MdJ
Registered User

Join Date: Jul 2010
Location: France
Boat: Etap 22i
Posts: 65
Hello,

My goal was to make the program a very simple tool.

Libbsb contains errors on color management and compression algorithm that I tried to correct (128 colors, depth to 2.3 ...).

Gdal does not generate kap file for licensing matters.

My tests with google google projection are not correct on first version OpenCPN.
(satellites see Earth as a sphere, the projection OpenCPN and marine software consider an ellipse.)
So I modified the program to fit the image.


I thought to make several changes,
- Use ImageMagic or GraphicMagics code to accept any image format by reducing the number of colors the better.
- Add an optional polygon useful in giving the edge image.
- Provide points of positioning image
This latest evolution is problematic because it may require a distortion of the image difficult to achieve, if the image is not a simple image.
For example, if you use an old map from before 1800.

I agree to modify the program and would appreciate your opinion on priorities.

M'dJ
MdJ is offline   Reply With Quote
Old 30-01-2011, 08:49   #4
MdJ
Registered User

Join Date: Jul 2010
Location: France
Boat: Etap 22i
Posts: 65
Another remark,
libbsb merely copying the header files kap without any treatment.

Initially, my goal was to use OpenCPN during my vacation on a PC 1002HA Azus with satellite imagery, what I did.

Initially I thought that my program could be useful but libsb no longer active, I can not put my code.

If you want an option to do the same thing libbsb is very simple.

Regards,
M'dJ
MdJ is offline   Reply With Quote
Old 30-01-2011, 08:54   #5
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
Editing with tiff2kap

Click image for larger version

Name:	GoofyEdit.jpg
Views:	196
Size:	109.2 KB
ID:	23298

Before I read all that above,I can do this in 5 minutes...please don't burst my bubble!
Edit..I can't see any trouble with borders...per tiff2bsb etc. but I see per 0,0 versus 1,1 what you might mean.Still,one pixel isn't much?beyond normal gps error...having a fathom option a la map2kap might be nice.

What I like is the speed and multi-options.I can even make tif tempplates per positions.I can choose my own image editor and calibrate from many sources.Also,although the diagonal corner might seem a loose calibration,logically it seems more sure than trying to place crosshairs per Map_Cal2 and building the underlying grid from that...?
HappySeagull is offline   Reply With Quote
Old 30-01-2011, 09:48   #6
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
Per my own example above,I get a shift new-to-old 16feet north,7feet west
Reports by OpenCPN:
GoofyChart scale 1:14950 WGS84
Original 1:15000 NAD83
chart is 2.5 x 3.75 miles

between tif2bsb and irfanview's multiple saves as tif ...I'm not exactly clear yet where the error gets in but as is seems useful.
HappySeagull is offline   Reply With Quote
Old 30-01-2011, 10:54   #7
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
Click image for larger version

Name:	unhappyreef.jpg
Views:	173
Size:	92.3 KB
ID:	23303
or this per mobilemapcreator and irfanview.
HappySeagull is offline   Reply With Quote
Old 01-02-2011, 08:09   #8
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
Suggestions from a user?

...Using OpenCPN and without even closing OpenCPN,writing down the positions of the corners (and thereafter converting to decimal degrees),next,using a"Printscreen"command,cropping that to window size and saving as 16color tif,making a kap with tif2kap into my chart folder then refreshing OpenCPN's charts,I get this...Click image for larger version

Name:	comparetiff2kapAndChart.jpg
Views:	176
Size:	86.9 KB
ID:	23392

You can see where the time went there...

I note the Waypoint realtime compared to waypoint "Printscreen"(above the 10).Would this tiny little jog up and left be 0,0 vs 1,1 pixel?

Other methods still do seem more convoluted to me. Without installing anything else into Windows, I think this is hard to beat ...and, the tif (with it's corners noted for later use)are now a chalkboard that can be painted photos pasted in text written etc.The slight rigamarole is pretty much the same in Google Earth.

If you were to include an image editor,can I say my vote would be something more "Windowsy"?and small? and that can capture just the FRAME as a tif in the first place?...that can edit and paint similar to the general run of Windows apps?

And maybe,M'dJ,you could have two versions?one writes Metres,one writes Fathoms...
HappySeagull is offline   Reply With Quote
Old 01-02-2011, 11:25   #9
Registered User
 
sinbad7's Avatar

Join Date: Sep 2003
Location: Ubatuba,SP,Brazil (Ex Norway)
Boat: (Ex) Alu. 60' yacht-"Eight Bells"
Posts: 2,731
Images: 57
Send a message via Skype™ to sinbad7
Happy Seagull..

Had a go using your tiff2bsb but it simply aborted saying 'program is no longer working'
I was trying to convert a .tif straddling East and West longitudes,perhaps that is the problem?

Most professional charts in bitmap format have the geo locations printed in the top left and bottom right corners in the format degree minute.000000 and I would suggest your program is set up accordingly to avoid conversions etc.

I will try later with a chart of the same longitude names to see if that works.
__________________
"And all I ask is a tall ship and a star to steer her by."
sinbad7 is offline   Reply With Quote
Old 01-02-2011, 12:15   #10
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
Quote:
Originally Posted by sinbad7 View Post
Happy Seagull..

Had a go using your tiff2bsb but it simply aborted saying 'program is no longer working'
I was trying to convert a .tif straddling East and West longitudes,perhaps that is the problem?

Most professional charts in bitmap format have the geo locations printed in the top left and bottom right corners in the format degree minute.000000 and I would suggest your program is set up accordingly to avoid conversions etc.

I will try later with a chart of the same longitude names to see if that works.
Yikes!Ya got me there...interesting problem across Greenwich and all..but this is tiff2kap I'm keen on....http://www.hisse-et-oh.com/pht/artic...9/tiff2kap.zip I think is the link?Or refer to Original thread I mention in my original post.
That said,
Tiff2bsb (from Libbsb folder) is a great way to get a nice compatible tif from a kap you have already that you would like to scribble on etc and sail around on...But to open these as huge full size images in 98% of image editors is like watching the tide rise....

I'm thinking that's a great tip per the corners of charts...I'm going to have a look right now!In the same vein,for MapCal_2 users...the 2 wanted image corner coords are right in front of you, on the main gui!
It takes me awhile to notice these simple things.
HappySeagull is offline   Reply With Quote
Old 01-02-2011, 12:19   #11
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
PS.Had another idea....per templates for reuse:There's no reason not to write the corner coords ONTO the tiff so anybody (passing this kap backnforth?) can easily edit it themselves the same way...
HappySeagull is offline   Reply With Quote
Old 01-02-2011, 13:07   #12
Registered User
 
sinbad7's Avatar

Join Date: Sep 2003
Location: Ubatuba,SP,Brazil (Ex Norway)
Boat: (Ex) Alu. 60' yacht-"Eight Bells"
Posts: 2,731
Images: 57
Send a message via Skype™ to sinbad7
HappySeagull.

Sorry my #9 had a misprint,I ment of course TIFF2KAP.
I haven't had time to check another chart within the same longitude but will report back.
I wonder how MapCal automatically finds the actual physical map corners geo locs?
Must be using some geo algorithm based on the geo locations already entered.

Tore
__________________
"And all I ask is a tall ship and a star to steer her by."
sinbad7 is offline   Reply With Quote
Old 01-02-2011, 13:11   #13
Registered User
 
HappySeagull's Avatar

Join Date: Dec 2010
Location: B.C.,Canada
Boat: 29'
Posts: 2,423
hmmm.Sinbadarn it,per "Pro" raster charts I've only got old bsb/kaps and these use calibration positions sprinkled liberally as to borders,major latlongcrossings etc.as in: (Warning:gobbledeegeek follows !: ...headers...REF/4,127,112,48.5498194,-123.5596417..REF/5,575,1485,48.4998194,-123.5346417..PLY/1,48.5498194,-123.5596417..PLY/2,48.5498194,-123.5096417..PLY/3,48.4831528, ...but none are on image corners 0,0 etc.Oh,well.
Edit:
...mmm.Figured twas misspell but had to blather in case of..
HappySeagull is offline   Reply With Quote
Old 01-02-2011, 13:54   #14
Registered User
 
sinbad7's Avatar

Join Date: Sep 2003
Location: Ubatuba,SP,Brazil (Ex Norway)
Boat: (Ex) Alu. 60' yacht-"Eight Bells"
Posts: 2,731
Images: 57
Send a message via Skype™ to sinbad7
I just converted a .tif chart to 127 colours in Gimp2 but as I saved it,it reverted to
256 colours and was not accepted by TIFF2KAP.

I think the PLY values you see are the corner geo locs. There are never more than 4 PLY's but any number of REF's are possible.
__________________
"And all I ask is a tall ship and a star to steer her by."
sinbad7 is offline   Reply With Quote
Old 01-02-2011, 15:01   #15
Obsfucator, Second Class
 
dacust's Avatar

Join Date: Feb 2008
Location: Southeast USA.
Boat: 1982 Sea Ray SRV360
Posts: 1,745
Quote:
Originally Posted by sinbad7 View Post
...
I wonder how MapCal automatically finds the actual physical map corners geo locs?
Must be using some geo algorithm based on the geo locations already entered.
Quote:
Originally Posted by sinbad7 View Post
...
I think the PLY values you see are the corner geo locs. There are never more than 4 PLY's but any number of REF's are possible.
The PLYs MAY be the corner geo-refs, but that's not what they really are. They define the area of the image that is chart, excluding the border. You manually plot these. There can absolutely be more than 4 PLYs. If you have a rectangular chart there would be only 4 PLYs, so most charts would fall into that category.

MAPCAL does not calculate the corners per se. But it does calculate the geo position of the PLYs when you plot them. So, if you plotted PLYs at the corners, it is calculating the geo of the corners. It calculates them based on how many pixels it is away from the REF positions you plotted and how far apart the REFs are. And possibly makes adjustments based on projection type, etc. The position it calculates for the corners may be off depending on what else you plotted and what parameters you entered. So, they may or may not be accurate.

In the case of a scanned image, there should only be 4 PLYs and these would be the geo-refs of the corners. But, there again, depending on how your REFs are plotted and what other parameters you entered, they could be calculated incorrectly. SO, what I said in the first 2 paragraphs might not really have any effect on how you would code your utility for scanned images, but I thought it might help just to know what the PLYs actually are, and my guess as to how MAPCAL is coming up with them.

-dan
dacust is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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


Advertise Here


All times are GMT -7. The time now is 02:06.


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.