How to make dark gray background on TIF image transparent or white in QGIS

How to make dark gray background on TIF image transparent or white in QGIS

see also: Imported TIF has dark gray background instead of white

That question addresses why the TIF imported into QGIS has a dark gray background when the color set is set to 4096 when exported from PDFCreator. That file's gdalinfo shows NBITS=4

Here, in this question, I would like to know if there is a way to render the dark gray transparent, much in the way that entering a "0" in properties->transparency->no data value->additional no data value will make the black lines transparent.

Alternatively, is there a way to have QGIS render the dark gray as white?

I looked at the histogram, and there is a huge peak at 15 for all bands. Two other tiny peaks are likely the colors of small bits of color. Setting the additional no data value to 15 got rid of all the gray, and left black lines.

However, it also turned full black the bits of color (themselves 'grayed' out just like the background was)

I could not figure out how to leave the color bits with some color. If anyone can tell me how to un-gray the color'd bits, let me know.

I tried playing around with the histogram min/max (I'm not sure if that is a display choice, or actually modifies the underlying image). I tried playing around with adding a custom transparency band (a single line, with entries in the three bands)((a '15' in bands duplicated the effect of the additional no data value of 15). I tried playing the drop down box, none/blue/etc, just at the top of the custom area, but couldn't figure out what it was doing.

How can I change a particular colour to transparent?

I have a photo with white background. I want to remove the white colour and make it transparent. The simple select and remove type remover don't help because the image is very complex. It has many tiny areas of white. I know how to change a particular colour to some other colour, but I don't know how to change a particular colour to transparent. Please help me.


To produce 7.5-minute quadrangle sheets for field verification maps, plotting raster data with point, line, text overlays was a straight-forward incorporation of the Arcplot image command in the Arc Macro Language (AML) file that generates the map. For example:

mapextent <pathname>/<filename> /* map area

mapunits meters /* unit of measure

mapposition ll .38 .73 /* location on the page

image <pathname>/<filename>.tif /* imagery

arclines <pathname/<filename> /* lines

pointmarkers <pathname>/<filename> 208 /* points

pointtext <pathname>/<filename> <field> /* text

In addition to plotting well points and identification codes or soil association groups on the DRGs, these text, point and line data were plotted on DOQ and National Aerial Photography Program (NAPP) raster format imagery. After the map extent and scale are set, the image command is issued followed by commands for appropriate vector data. Sequence is important. It is more efficient to write an AML assuming an opaque plotting format because the same file may be produced many ways--on a plotter (opaque or transparent), as a slide (opaque), or on screen (opaque). If text, points, lines, and area fills are plotted first, followed by imagery (or other area fills), the initial data will be overwritten by subsequent data as it plots (note that, in an image, white paper areas are also composed of value coded cells).

Foreground light blue, white, gray, yellow color texts are present. Colors that don't go with black color background are not visible.

I'll withold judgement until I actually see an image or link to your design, but it sounds like you're already trying to mix oil and water. There probably isn't a background color to solve that problem, so let's address the more interesting question.

a background color that goes with both black and white foreground text color.

The right orange (and many other hues) can pull that off. See this paletton, and imagine it with a heavier font:

The white and black text are acceptably readable (to me, at least). But that color as a full page background would be overwhelming. Here's the same palette desaturated a bit:

I think that looks ugly, but the black/white text is still fairly readable. Let's desaturate to almost gray:

Now it's more of a warm gray, and it doesn't look so bad. But we're starting to run up against the problem that ecc's answer mentioned. Let's fully desaturate to see what I mean:

Without the color saturation, the white and black text are too similar to the background, so they will be difficult and/or tiresome to read.

IMO, the second version (slightly desaturated) isn't overwhelming and the text contrast is acceptable. Too bad it looks like grasshopper vomit.

Finally, keep in mind that any of the above versions will look very close to the grayscale version under certain kinds of colorblindness (dyschromatopsia and achromatopsia). That's one of the reasons for this principle:

Background and text colors should have high value contrast, because hue and saturation contrast are too dependent upon individual perception and monitor/printer representation.

By using text that is white (value == 255) and black (value == 0), you are limited to a value contrast with the background of at most 127 (the middle of that range). For the sake of readability for most people on most devices, you should choose either bright text on a dark background, or dark text on a bright background. You can have bright text and dark text on the same page, just make sure they have different backgrounds:

The Easiest Way To Make A Transparent Signature Stamp

If you sign a lot of documents that are sent to you electronically in PDF format, you can save a lot of time by using a PDF stamp of your signature. This way you can simply stamp the document, flatten it, and return the document electronically instead of printing, signing with a pen, and scanning the signed the document. The problem is that if the signature stamp has a white background instead of a transparent one, the white will cover portions of the document:

There have been several articles written about how to make a signature stamp with a transparent background but many of these methods result in a fuzzy, poor quality signature stamp. I will outline the fastest method I have found that produces a high quality transparent background signature stamp using software that you probably have on your computer, and free online tools. It looks like a lot of steps but I break each step down into a short bullet point:


  1. Sign your name on a blank sheet of printer paper. Paper quality and type of pen doesn't really matter, just make sure your signature is straight and not on an angle.
  2. Scan the paper to PDF. With Acrobat Pro DC select File > Create > From Scanner > Color Document.
  3. Press the &ldquoPrint Screen&rdquo button on your keyboard.
  4. Open Microsoft Paint.
  5. Press Ctrl + v on your keyboard to paste the screen shot from step 3.
  6. Click the select tool in Paint.
  7. Drag a rectangle around the signature staying as close as possible to the outer edges of the signature.


  1. Find a free online image converter by Googling &ldquoConvert Image To Transparent Background Online&rdquo and use the image converter to make the background transparent. When I Googled that, number one was Lunapic ( ). The next steps use this particular tool to convert the image to one with a transparent background.
  2. Click &ldquoChoose File&rdquo and upload the .png file from step 9.
  3. From the Lunapic toolbar, select Edit > Make Transparent.
  4. Click a white part of the image.

This shows the transparent image.

14. Click &ldquoSave&rdquo and save the new transparent signature to your desktop.

  1. Select the stamp menu on the Acrobat Pro comments toolbar menu and select Stamps > Custom Stamps > Create.
  2. Click the &ldquoBrowse&rdquo button in the dialog window, change the file type dropdown to &ldquo.png&rdquo, browse for and select the transparent signature file from step 14.
  3. Click &ldquoOpen&rdquo.
  4. Click &ldquoOK&rdquo.
  5. Name the stamp category (something like &ldquoMy Signatures&rdquo or you can select the pre-existing &ldquoSign Here&rdquo from the dropdown menu).
  6. Name the stamp.

1 Answer 1

The MP4 format doesn't support an Alpha channel. The question you've asked is very broad, and I've tried to answer to a certain extent below. However you may need to decide what route you're going to try and then researching that route or asking further, more specific questions.

The file types that currently support an Alpha (transparency) channel are FLV, F4V, AVI, Quicktime, and WebM. If you're using free programs, you may find they can export in these formats. Often, there will be a named codec for an Alpha channel within the settings of these, or a PNG option. Firstly, I would see if there's an option to export video within your PyMOL software in any of these formats - try exporting them in different ways to see if they have the Alpha channel.

Alternatively, if it's a one off video, you could use the free trial of Premiere Pro or After Effects to create and export your video, although it can be a learning curve if it's a complex project and you have never used Adobe Creative Cloud before. Lastly, you could export your video and try and remove the background in a video editor. (If you want to use WebM, you need a third-party WebM codec for Adobe Media Encoder.)

PNG import /export

You could import the png sequence into either After Effects or Premiere Pro (free trials available for each). I'm sure several free programs can import a PNG sequence automatically, or you could manually arrange the images on the timeline, one image per frame.

I mainly use Premiere Pro so below I've listed a couple of ways I can use it to export a transparent video directly from Premiere. HOWEVER - there are likely to be similar options in other programs - most video programs will export in a variety of formats / codecs.

###Export a movie file with an alpha channel in Premiere Pro ###

  1. Select the sequence.
  2. Choose File > Export > Media.
  3. In the Export Settings dialog box, choose one of the following options:
  • Select "QuickTime" in the file format
  • Select "PNG" from the video codecs
  • Under Channels, select "RGB + Alpha"
  • Select "AVI" in the file format
  • Select "RGBA + " from the video codecs
  • Under Channels, select "RGB + Alpha"
  1. Once you have changed settings as per one of the sets of options above, continue to set other settings and click Export or Queue to export as you normally would.

Remove background

Another option is that if the background is a consistent colour - white, grey, green etc, most advanced video editors will have options to remove the background using a colour match.

In Premiere Pro, this is done using the Chroma key effect. In essence, add the effect to the video, take a sample of the background colour, and the background should be removed, it's just left for you to export the video in one of the methods mentioned previously.

2 Answers 2

Unsharp Mask will increase contrast, but it works by exaggerating local differences. You probably do want to use Unsharp Mask in the processing of an image like this to increase the amount of contouring, but it's not the best way to go about fixing the major tonal issue.

You can't really say that there isn't enough total contrast in the image, since you have blown-out white areas and some absolute blacks. The problem is that there isn't enough contrast in the "interesting" parts of the picture — the hair isn't dark enough, and the part of the white shirt that isn't a highlight isn't quite light enough. You can use a curve to fix that (I don't have Gimp, and I figure that Gimp users are pretty tired of seeing Photoshop examples everywhere, so I'm using the Curves adjustment from Paint Shop Pro 9 just to show that it doesn't have to be Photoshop to work):

Note the "S" shape that increases the amount of contrast in the mid-range of tones, making things that are not quite black darker and things that are not quite white lighter. That will make the picture "pop" quite a bit more than it does with the original tones:

The curves adjustment can go quite a bit further than I've gone here without damaging the image in any way. Honestly, the adjustment looks a lot bigger with the before and after in the same place (turning the layer with curves on and off) than it does here, so I probably should have been more extreme with the example. I was leaving room for the next step.

If the shapes aren't quite "3D" enough at that point, you can use a large-radius Unsharp Mask at a fairly low strength to boost the contours a bit, but whether you want to (I probably would) and how much/what settings is a matter of taste and personal preference. But you'll be starting with an image that has a better contrast range where you want it, so you shouldn't wind up with something that looks over-processed.

It looks like the background image area for the tile gets it's alt attribute set as the link item's title. So you can use the following to target a single specific tile:

.ms-promlink-body img[alt*="text from the title"]

where "text from the title" is some text that will uniquely identify the target tile based on it's title.

If you use :first: or eq(2) etc. and reorder the tile list, the colors will not follow suit. Another option is to identify the webpart ID and actual tile ID (using dev tools) on a page, and then use the following:

Line 1 - first 3 are set to all the same color, Line 2 & 3 - different colors. Tile is the list name, WPQ3 & WPQ2 is the webpart, _12 is the tile ID and _2 is the layer on the tile where the div/block background color is set.

This method is applied to the page the tiles are displayed on, not site-wide, and if you add more webparts to the page, you may need to tweak the WPQ #.

Background & Summary

Vertebrate fossils are often broken upon discovery and during excavation, and must be reassembled for research and display. This is especially true for specimens preserved on bedding planes in thinly laminated sediments, which can completely shatter. Simply gluing together the broken edges rarely yields a structurally sound specimen because the edges are too thin. Repair commonly involves mosaicking the broken pieces together, using plaster or grout, onto a stable ‘backing-slab’ that provides structural integrity. The product is a three-layered object whose ‘stratigraphy’ is man-made (Fig. 1).

Volumetric rendering from CT data (Data Citation 1) showing its 3-layer man-made stratigraphy. The top layer is only 2–8 mm thick and was shattered during excavation. It was mosaicked together using a ceramic grout on a backing slab that provided structural integrity. Edges of the top bone-bearing layer are colored red the middle layer consisting of grout is green and the backing slab is gray.

A two-century-long history indicates that this type of reassembly is prone to inadvertent error and willful forgery 1–7 . Surface layers often include extraneous pieces to fill voids around the restored skeleton. It is not uncommon to discover that bones from different specimens, even taxa, were combined to create the impression of a single ‘complete’ skeleton. Surfaces are often painted and textured to disguise repairs and give visual continuity to the whole. For larger specimens, it was once common practice to build a structural wooden frame around the reconstructed slab that obscured its ‘stratigraphy.’ Painted or grouted edges also hide evidence of reconstruction and obscure interpretation.

Once reassembled, these are generally considered to be ‘specimens’ in the conventional sense. Here, we emphasize that they are more aptly viewed as ‘amalgamations’ since they often comingle associated bone-bearing pieces with extraneous rocks and consolidating materials. Unrecognized extraneous elements can lead to cascading errors in scientific analyses.

The problem grew significantly in the last two decades as fossiliferous deposits in China began to yield prodigious quantities of fossils, many of which were quite complete and well-preserved 8–24 . However, many of the new specimens, including holotypes, were reportedly excavated and reassembled autonomously by local farmers who sold them to private collectors, researchers, and museums 25–29 . In such cases, a scientific ‘chain-of-possession’ is difficult to establish 25–34 . Although strictly illegal 35 , commercialization of Chinese fossils and a quasi-free-market of fossil trade are widespread owing to weak law enforcement 36 . Commercialization also provides financial incentives to cosmetically enhance imperfect fossils, causing scientific damage 26–29 .

Some prominent scientists claim that ‘Normally we know right away if a fossil is a fake…’ 34 . Indeed, a published fossil skull 37 was recently exposed as a forgery using conventional techniques 38 and the publication was retracted 39 . But conventional preparation is limited by its invasive nature, and for logistical and technical reasons other scientists concede that ‘Authentication is not easy’ 34 .

With this widely recognized problem, we endorse the recommendation that authentication of fossils not directly collected by scientists should be a required research protocol 36 . Chinese authorities have taken legislative steps to prevent illegal trafficking in fossils 35,40,41 but a black market has existed for years 26–29 and concerns are voiced that ‘The fake fossil problem has become very, very serious’ 34 . These problems, highlighted by China, are global in nature 1–4,7 .

Computed tomography (CT) has been used for 30 years to nondestructively inspect the entire 3D volumes of fossils 42–48 . CT can reveal many features otherwise invisible such as endocasts of the brain 49–53 and inner ear 54,55 . Several amalgamations and forgeries have passed through the University of Texas High-Resolution X-ray Computed Tomography Facility (UTCT) in its 19 years of operation. Here, we describe protocols that we developed to authenticate fossils by validating the associations between pieces and to identify extraneous elements 6 .

More general application of CT to forensic problems in paleontology is hindered by the lack of exemplar datasets and published assay procedures. We describe three datasets from Early Cretaceous lacustrine deposits of Liaoning, P. R. China that illustrate the use of CT in forensic analysis. The first is a specimen of the primitive bird Confuciusornis 56 that was shattered and reconstructed with relatively minor errors. The second is the so-called ‘Archaeoraptor’ 57 , a chimaera of multiple taxa 6 . The third is a nearly perfect specimen of the primitive mammal Jeholodens 58 . Our intention is that these datasets may assist others in properly interpreting CT imagery to evaluate the integrity of individual specimens, and to extend the application of CT in authenticating fossils.

Watch the video: Landsat 8 Image Classification using QGIS