Make Raster Image Transparent by Altering the text in Tab file (RASTERSTYLE)

306 views
Skip to first unread message

Archie

unread,
Jul 27, 2008, 8:58:32 PM7/27/08
to MapInfo-L
Dear List-ers,

Good day!

I want to make a the white parts of a raster image transparent.

I was able to find some links that discuss "rasterstyle". I edited the
tab file that links to the raster image.

Here is the code in the tab file:

+++++++++++++++++++++++++

!table
!version 300
!charset WindowsLatin1

Definition Table
File "rasterimage001.tif"
Type "RASTER"
(0,1) (0,0) Label "Pt 1",
(1,1) (1,0) Label "Pt 2",
(0,0) (0,1) Label "Pt 3"
CoordSys NonEarth Units "ft"
Units "ft"
RasterStyle 4 1 ***
RasterStyle 5 255 ***

+++++++++++++++++++++++++

*** I have added these two extra lines into the code but do not seem
to work when I open the file in MapInfo.

Any suggestions/comments, if this is even possible, would be greatly
appreciated.

Cheers,
Archie

Archie

unread,
Jul 27, 2008, 9:45:18 PM7/27/08
to MapInfo-L
Hi again!

I found out how to do it, as long as the raster image is in ".tif"
format. But I can't make it work with JPEG images.

Thanks anyway!

Cheers,
Archie

Driver, Greg 9434

unread,
Jul 28, 2008, 3:53:59 AM7/28/08
to mapi...@googlegroups.com
Archie,

Probably the easiest way to find out what code to put in the Tabfile is
to open one of the JPEG images in MapInfo and then set the 'white space'
to be transparent via Table -> Raster -> Adjust Image styles. You can
then open the Tabfile in NotePad (or other text editor) and see what
code has been added to enable the transparency.

HTH

Greg Driver

System Administrator
Applications Support
ICT
Surrey Police
NOT PROTECTIVELY MARKED
*Internet communications are not secure and therefore Surrey Police does not accept legal responsibility for the contents of this message. This email and any attachments may be confidential. They may contain privileged information and are intended for the named addressee (s) only. They must not be distributed without our consent. If you are not the intended recipient, please notify us immediately and delete the message and any attachments from your computer, do not disclose, distribute, or retain this email or any part of it. Unless expressly stated, opinions in this email are those of the individual sender, and not of Surrey Police. We believe but do not warrant that this e-mail and any attachments are virus free. You must therefore take full responsibility for virus checking. Surrey Police reserves the right to monitor all email communications through their networks.*

Shunfeng ZHANG

unread,
Jul 28, 2008, 6:14:40 AM7/28/08
to mapi...@googlegroups.com
Hi Experts,

I used a excel table to "create points". The excel table contained of
course Longtitude and Latitude.

The MapBase window in MapInfo windows showed only:

Create Map For EFR_AMR_FR_DL_2 CoordSys Earth Projection 1, 104

How do I specify the column for Longtitude and Latitude when I program
in MapBasic?

Best regards!

Shunfeng


Timothy Mashford

unread,
Jul 28, 2008, 6:56:57 PM7/28/08
to mapi...@googlegroups.com
JPEG is a lossy format so it won't contain a 'pure' white value, if
you zoom in you will see it's speckly with various shades. This is why
the 'set transparent' won't work, because it chooses only a single
colour value.

It would be good if the user could set a tolerance, similar to the
wand tool in photoshop.

Tim

Archie

unread,
Jul 28, 2008, 8:00:52 PM7/28/08
to MapInfo-L
Hi Greg,

It worked! Thanks for the suggestion!

Cheers,
Archie

On Jul 28, 5:53 pm, "Driver, Greg 9434"

Williams, Bill (DPS)

unread,
Jul 28, 2008, 8:28:09 PM7/28/08
to mapi...@googlegroups.com
Greg/Archie
I've just tried your method of making the background of a raster image
transparent.
The attached image is included in every map created in the section, but
the background is opaque white.
Using your method, I can make the majority of the image transparent but
a rectangle of opaque white remains around the coat of arms. If I make
the background of the COA transparent, the remainder of the raster
returns to opaque white.
Any suggestions please ?

Bill Williams
Senior Researcher, Statistics & Mapping Section
Parliamentary Library
Department of Parliamentary Services
Parliament House
PO Box 6000
CANBERRA ACT 2600
Telephone : 02 62772513
Email: bill.w...@aph.gov.au
ParlLibHeaderMerged.jpg

Lars I. Nielsen (GisPro)

unread,
Jul 29, 2008, 3:02:23 AM7/29/08
to mapi...@googlegroups.com
Hi Bill,

This is a graphics problem, not a problem with MapInfo as such.

The JPEG has most likely been created using anti-aliasing, which renders border pixels between black and white in a shade of gray.

In MapInfo, you can only assign transparency to a single RGB value, so whenever you choose another color, the previously assigned transparent white returns to opaque.

You need to reset your raster image to a pure black and white state. To avoid pixellation issues, what anti-aliasing was introduced to minimize, you may need to increase the dpi from say 300 to 600 first.

Best regards / Med venlig hilsen
Lars I. Nielsen
GIS & DB Integrator
GisPro


Williams, Bill (DPS) skrev:

Gentreau

unread,
Jul 29, 2008, 3:07:02 AM7/29/08
to mapi...@googlegroups.com

Bill, try this copy of the image.

The only change I made was to convert it from 256 colours to 2 colours.
That way you can be sure that the white is only white.
It's common for an image to have some grey pixels around the edge of a
sudden colour change, which is probably what you saw as the halo around the
COA.

I have saved it as a TIF because JPEG is always saved as either 256
greyscales or 16 million colours.

BR
Gentreau.

ParlLibHeaderMerged_2_colour.tif

Williams, Bill (DPS)

unread,
Jul 29, 2008, 7:15:44 PM7/29/08
to mapi...@googlegroups.com
Gentreau/ Lars I. Nielsen
Thanks heaps for the prompt reply.

Gentreau, that has made life easier for me in that now I can have a
background colour and the logo on it without the horrible white opaque
background spoiling the look of the map. I assume the surgery you
performed on the original logo can be performed on other rasters as
well.
A last request. How did you convert from 256 to 2 colours ?

Seems I owe you both a beer now.

Gentreau/Lars - Thanks mate.

Regards

Gentreau

unread,
Jul 30, 2008, 1:10:57 AM7/30/08
to mapi...@googlegroups.com

Hi Bill,

All I did was to open it in PaintShop Pro, select Decrease colour depth ...2
colours
and then save it as a tif or gif. Whole operation took about 10 seconds.

If you have any others and you cant convert them, send em by email.

Williams, Bill (DPS)

unread,
Jul 30, 2008, 1:27:29 AM7/30/08
to mapi...@googlegroups.com
Gentreau
Thanks. I'll give it a try.
Regards
BillW

arunas.urbsys

unread,
Jul 31, 2008, 4:04:08 AM7/31/08
to MapInfo-L
PaintShop Pro probably is shareware or commercial software. If you
need just to play with decreasing the color depth of the images, try
grat freeware software IrfanView (http://www.irfanview.com/).

I have been using IrfanView for may years now (perhaps some 8 or 10
yrs) for preparing scanned images to use in MapInfo. It has very
powerfull color resampling engine so that reducing true color (16,7
million colors) images to 256 colors makes almost no visual effect to
image quality. So, if for example I receive a scanned map in TIFF
format in true color, in size of over 200 MB, then resample it to 256
colors and save in GIF format, I get some 30 MB image, which saves a
lot of space and does not reduce the quality.

Best regards,
Arunas Urbsys
GIS Project Manager
arunas...@gmail.com
> Email:   bill.willi...@aph.gov.au
> Email:   bill.willi...@aph.gov.au
> monitor all email communications through their networks.*- Hide quoted text -
>
> - Show quoted text -

Gentreau

unread,
Jul 31, 2008, 4:33:20 AM7/31/08
to mapi...@googlegroups.com

PaintShop Pro is now owned by Corel, but I have an old version which I
bought some years back at a very sensible price.
It is old, but does everything I need to do in terms of image manipulation.

I'd agree though, if you don't have such a program already, there's no point
paying for one if you are only using a single function. I suspect that GIMP
also does colour depth reduction too.
Reply all
Reply to author
Forward
0 new messages