Cutting noise from photos

UPDATE: March 2023 – I am currently using DxO PureRaw instead of the full PhotoLab. It does the same with denoising and lens/camera corrections. I then adjust curves and levels with PaintShopPro as I had been doing prior to trying PhotoLab.

UPDATE: January 2023 – I wrote this article back in 2018, since then various programs have come on to the market that offer AI approaches to denoising photographs many of which are much easier to use and work really well. For example, the Topaz AI Denoise tool reduces noise and blur and can even reduce motion blur, as I demonstrated in an article with a photograph of a Peregrine Falcon flying overhead. DxO Photolab is my current denoise software of choice though, its DeepPrime system effectively lowers the ISO of any noisy photograph by the equivalent of about three stops (like shooting at 400 rather than 3200 but with the same shutter speed and aperture). It lens/camera corrections built-in too as well as allowing you to adjust levels, curves, saturation etc etc.


Noise can be nice…look at that lovely grain in those classic monochrome prints, for instance. But, noise can be nasty, those purple speckles in that low-light holiday snap in that flashy bar with the expensive cocktails, for example. If only there were a way to get rid of the noise without losing any of the detail in the photo.

Now, I remember noise in spectroscopy at university, you could reduce it by cutting out any signal that was below a threshold. Unfortunately, as with photos that filtering cuts out detail and clarity. So, a solution was to run multiple spectra of the same sample, like taking the same photo, you could then stack them together so that the parts that are of interest add together. You then apply the filter to cull the dim parts, the noise. The bits that are the same in each shot (or spectrum will be added together, but the random noise will generally not overlap and so will not get stronger with the adding. The low-level filtering then applied will remove the noise and not cut the image. No more ambiguous spectral lines and no more purple speckles. That is in theory, at least. Your mileage in the laboratory or with your photos may vary.

De-noising by stacking together repeat frames of the same shot comes into its own when doing astrophotography where light levels are intrinsically low. Stack together a dozen photos of the Milky Way say, the stars and nebulae add together, then you can apply a cut to anything that isn’t as bright as the dimmest and you can reduce the noise significantly. Stack together a few hundred and your chances are even better, although you will have to use a system to move the camera as time goes on to avoid star trails.

Then it’s down to the software to work its tricks. One such tool called ImageMagick has been around for years and has a potentially daunting command-line interface for Windows, Mac, and Unix machines, but with its “evaluate-sequence” function it can nevertheless quickly process a whole stack of photos and reduce the noise in the output shot.

As a quick test, given it’s the middle of the afternoon here, I went to my office cupboard which is fairly dark even at midday, and searched out some dusty copies of an old book by the name of Deceived Wisdom, you may have heard of it. I piled up a few copies and with my camera on a tripod and the ISO turned as high as it will go to cut through the gloom, I snapped half a dozen close-ups of the spines of the books. The first photo shows one of the untouched photos, with a zoom in on a particularly noisy bit.

Next I downloaded the snaps, which all look essentially identical, but each having a slightly different random spray of noise. I then ran the following command in ImageMagick (there are other apps that will be more straightforward to work with having a GUI rather than relying on a command prompt. Nevertheless, within a minute or so the software has worked its magic(k).

magick convert *.jpg -evaluate-sequence median book-stack.jpg

And, so here’s the result, well the zoomed in area of the composite output photo, the average of the six essentially identical original frames with the noise filtered to a degree from the combined image. There is far less random colour fringing around the letters and overall it’s crisper. The next step would be to apply unsharp masking etc to work it up to a useful image.

It’s not perfect, but there is far less noise than in any of the originals as you can hopefully see. The software you use can have fine adjustments, but perhaps the most important factor is taking more photos of the same thing. That’s probably not going to work at that holiday cocktail bar, but with patience should work nicely for astro shots. Of course, if I wanted a decent noise-free photo of my book, I could have taken them out of the cupboard piled them on my desk, lit them properly, used a flash and diffuser and what have you and got a really nice photo with a single frame. But, then what would you learn from me doing that other than that I still have copies of my old book?

Does hotter water freeze faster than cold?

UPDATE: Whether this proves to be right or wrong, my feature was the most well read article on Chemistry Views in 2017.

It sounds like #deceivedwisdom, but there are lots of reputable scientists who believe the Mpemba effect wherein hot water freezes faster than cold water is real. Youtube was replete with videos of people fling pans of boiling water into Canada’s freezing winter air to make clouds of “snow” and their friends with cold water attempting the same and simply getting a puddle in the snow. That effect is probably more to do with rapid evaporation and crystallisation than the Mpemba effect, but it makes for a great show nevertheless.

A couple of years ago, I believe The Royal Society of Chemistry (RSC) ran a competition to find an explanation for the actual Mpemba effect in which a container of warmer water placed in a freezer seems to become ice faster than a container of cold water. There have been very few validated, reproducible experiments on this surprisingly. And, in a recent Chemistry World, of which I only just got wind, a Cambridge team claims to have shown that there is no effect, it is deceived wisdom.

But…

I was sent a research paper that used calculations and vibrational spectroscopy to show that there are some sixteen different types of hydrogen bond present in water and that the distribution of types changes with temperature. Essentially, there being much tighter H-bonds (despite thermal agitation) in hotter water than cold. It is this distribution that means hotter water can nucleate more rapidly on cooling and form microscopic ice crystals that seed the liquid and allow it to freeze faster. You can read more details in my recent Chemistry Views article on this topic.

Incidentally, the snow-making videos are something of a distraction, this isn’t what Cremer and his team are talking about really, and they probably show rapid evaporation and crystallisation rather than the difference in ice formation caused by temperature difference.

What do you think? Is the Mpemba effect deceived wisdom or can different populations of hydrogen bonds persist and override the simple thermal effects and heat loss processes in water?

UPDATE: Dana Roth at Caltech just pointed to another paper that seems to support the existence of the effect and has a similar explanation re H bonds and nucleation.

Secret Spectroscopy

A safety initiative at Cambridgeshire’s well-known “Secret Garden Party” music and whatever festival saw the local police collaborating with an organisation called The Loop to test festivalgoers illicit drugs and make sure they were staying safe.

The Loop team had a 25 grand FTIR spectrometer to do the testing and if it showed up contaminants they’d advise users to ditch their product and get back to enjoying the music and dancing instead. The Guardian described the initiative as pioneering, which it was in the UK, although similar services have been running in Austria, Switzerland and The Netherlands for years (the UK lags way behind on drug policies, what a surprise). Although The Vice reports that only 250 drug samples were tested. There were some nasties that showed up in the spectra a lot of sugar used to cut MDMA, antimalarials that had been sold as cocaine, and some pills that were actually just cement.

The Loop is a team of experienced drug workers collaborating with analytical chemists. If someone offered up a sample of their drugs for testing, the team would hang on to that sample after testing and the users were offered an amnesty so they could hand over the rest without charge or they could opt to keep them but given some advice on drug abuse. It was all about safety and not policing.

Loop team member Henry Fisher had this to say in The Independent:

What has been demonstrated in a small corner of a field this weekend is something more fundamental: treat people who want to use drugs with respect, and they will respond to the advice given to them sensibly. If such enlightened thinking were applied more widely to UK drug policy, the returns in reduced drug deaths and hospitalisations would be vast. That really would be cause for a serious party.

Paradoxically, the festival’s website FAQ stated this: “Please be aware that The Secret Garden Party does not tolerate illegal drug use. Anyone caught using or distributing illegal drugs will be severely reprimanded. Drug detection dogs will be working on the gates in order to stop any illegal drugs entering the site. There will be a police presence inside the event, please respect them. Drugs are ILLEGAL.”

I asked Loop team member Jens Thomas for the skinny on the FTIR for my SpectroscopyNOW column:

“The FTIR is fantastic as far as it goes, as it allows us to identify a sample in under a couple of minutes and feed that back to the drugs workers so that they can advise the client on how to proceed safely if they are resolved to take the drug,” Thomas told me. “For probably 80-90% of what we see, the FTIR is enough; we can identify the primary component and then run a simple subtraction analysis to see if the sample is substantially adulterated with anything else.”

Adding, “However, as we work with more samples, we are seeing where the limitations of the technique lie. Some of the binders and fillers in ecstasy pills can mask the signal from MDMA, so we need to run a solvent extraction to extract the active component, and then analyse the extract with the FTIR; which obviously adds considerably to the time and effort required to get a result. Also some drugs are so potent (e.g. LSD) that they are present in such trace quantities that we cannot see them with the FTIR. In addition, FTIR is only (currently) a qualitative technique, so we need to run additional tests in order to quantify the MDMA in a pill, as this is crucial information for someone considering taking it. Some of the pills are so strong (>200mg) that taking two (double-dropping – something that used to be very common a few years ago when pills were weaker) could be pushing into lethal dose territory.

We are therefore looking to augment the FTIR with additional techniques, firstly to extend the range of what we can test, but also to provide additional confidence in the results we’re getting from the FTIR. Mass spec is something we’re interested in as it seems to have the sensitivity required and the latest machines are robust and portable enough that we could consider using them in the sub-optimal conditions we usually work in – i.e. knee deep in mud at festivals!”

Roundup: forming hydrogen, butterfly effect, arsenic and photonic mixtures

Forming hydrogen – The gas can be released efficiently from liquid formic acid for use in fuel-cell powered vehicles. Proof of principle utilised nuclear magnetic resonance (NMR) spectroscopy to follow the catalytic chemistry involved in the process. More…

X-rayed butterfly - Researchers have used X-ray coherent diffractive imaging to take a close look at how the photonic crystals on the surface of a butterfly’s wing generated the brilliant iridescent colours we perceive. More…

By C.T. Bingham – Fauna of British India – Butterflies (Vol. 2), Public Domain, https://commons.wikimedia.org/w/index.php?curid=2897500

Atomic arsenic – Researchers in Argentina have developed an optimized flow injection hydride generation atomic absorption spectroscopy (FI-HGAAS) method for the determination of total arsenic concentration in various foods. More…

Now the twain shall meet – Future quantum computational and other devices might rely on the mixing of photons and molecules. Now, researchers in the UK have demonstrated how a single molecule trapped in a tiny optical cavity can emit a photon, but that particle of light re-enters the molecule before it leaves the cavity, mixing molecule and photon completely. More…

 

 

Healthy green coffee

Last month I reported on research into “green” coffee for SpectroscopyNOW. From a quick glance at the reader statistics it looks like it was one of my most popular articles in recent months. What is it about coffee? We’re fascinated…

coffee-cup

Anyway, the story discussed how unroasted, green, coffee beans have become a popular alternative to regular coffee because of supposed health benefits, but there was little solid evidence of mineral availability or antioxidants from a green coffee drink that might support the claims.

Now, a team at Wroclaw University of Technology, in Poland, have used a sophisticated analytical technique* to measure how much calcium, copper, iron, magnesium and manganese ions are released into an infusion depending on whether or not the drink is made “in the cup”, using a drip filter or the Turkish coffee method. They found that calcium and magnesium are released (and so can be ingested) better than the other mineral ions but only if drip filtering or Turkish brewing was used rather than making it in the cup**. Tests on antioxidant activity also correlated with those brews from which the most calcium was leached.

*High-resolution-continuum source flame atomic absorption spectrometry
**My photo of a frothy fern in my coffee, not green coffee, unfortunately, roasted

All that MRI jazz

Brain scans reveal that different parts of the brain light up when jazz musicians are improvising and “trading fours”, when they’re engrossed in spontaneous, improvisational musical conversation. The specific parts of the brain that are activated are those associated with the interpretation of the structure of phrases and sentences, the syntactics. Conversely, the musical “conversation” leads to reduced activity in brain areas linked to meaning, the semantics. I report more details in my latest column on the MRI channel at SpectroscopyNOW.com, but I also spoke to Joe Thompson, Musical Director of London’s “The Club at the Ivy” to get a jazz musician’s perspective on the research.

piano-keys

“Exchanging fours with a great jazz musician offers a freedom of expression far greater than the spoken word can ever hope to obtain,” he told me. “At best, it is a dialogue of emotions, a communion of feelings. Youre contradicting, testing each other, challenging and daring each other. You’re sharing experiences, enjoying a joke and a laugh. It’s a game of tennis, a fight, a dual. It is meticulously calculated one moment and blind risk the next. It’s a dance, a shared tribute. One minute you are Andy Murray and Rafael Nadal, the next you are Torville and Dean, Morecambe and Wise, whoever you want to be. A random blend of the highly sophisticated and the base, it can be highly cerebral as well as utterly naive. You share, you compliment, you clash. It’s a two-minute marriage.”

Thompson, who has collaborated with Elvis Costello and Diana Krall among others, suggests that it can feel primeval. “The most exciting, provoking, fulfilling exchange of fours I had (on piano) was with a guy on a djembe (African drum). He not only made me do things I didn’t know I could do, I played things I didn’t know I wanted to play,” he confessed.

There is a suggestion that a musical exchange somehow bypasses the brain, at least that is hw it feels to Thompson. “You are spontaneously playing what you feel at the precise moment you feel it,” he adds. “You breathe his music in, and your music out. How you play and what you play depends on many things. The best improvising is of the moment and in the moment. Compared to all of this, a spoken dialogue is a walk in the park.”

Of course, he points out that when we communicate with each other we are doing a lot more than listening to, processing and returning the spoken word. “In close-up, face to face dialogue, all of the senses are used, as they are when playing music with someone,” he says. “Is the brain working harder in the jazz dialogue than in a situation where a terrified bloke is chatting up the love of his life, knowing he only has one shot at it? Who knows? But, I don’t think you need an MRI to tell you that the brain is working in similar ways in each situation.”

From the scientific perspective, we do need that MRI scan to provide the physical evidence for what is happening in the brain and you can read the details on SpectroscopyNOW.

This year’s bright young thing

You will have seen the news recently that a new supernova has appeared in the sky. This one is quite close, a mere 12- million light years (more than 1020 kilometres from Earth. I reported on it at the time for SpectroscopyNOW

SN2014J-supernova

“Astronomers have planned observations using the Hubble Space Telescope operated by NASA and the European Space Agency as well as NASA’s Chandra X-ray Observatory, Nuclear Spectroscopic Telescope Array (NuSTAR), Fermi Gamma-ray Space Telescope, and Swift missions in order to glean as much information about the recent supernova flare-up SN 2014J, in galaxy M82 as possible.”

I now have some additional thoughts from team leader Steve Fossey of the UCL group that first spotted this object in the night sky while simply doing a telescope student workshop because it was a cloudy night. I asked him what’s next:

“Results from the AAVSO website indicate it has peaked and is starting to fade. Typical fade rates for these objects are about a factor 2.5 every fortnight. While this requires urgent observations now, this actually means that we will be studying this object for a long time to come, and it will remain visible in amateur and small-telescope imaging for many weeks for sure. Professional facilities will follow it for months (and it is well placed in the sky to do so),” he told me.

He points out that there is an urgent need to observe the development and evolution of the SN as the shock wave and radiation field interact with the surrounding circumstellar medium. “One critical matter is the question of when ‘first light’ occurred, as this helps to constrain the size of the supernova progenitor – we expect a degenerate star such as a white dwarf, but of course this can never be directly observed (unless it were so close that this would be apparent in pre-SN imaging – but not in this case). The early light-curve shape also helps to investigate the nature of the expanding fireball – there is a paper just out on arxiv (Zheng et al., 2014, http://arxiv.org/abs/1401.7968) in which so-called “prediscovery” data have been used to pin down the time of first light – and it implies a very rapid early rise in brightness, much faster than simple scaling arguments for the brightness of the expanding fireball imply. This is not well understood (see Zheng et al.)”

Fossey suggests that searches for evidence for the putative companion will be sought through pre-explosion imaging data, such as in archival Hubble Space Telescope images. He adds that, “The Swift UV and X-ray observations are crucial also for detecting the impact of the explosion on the putative companion star, and on the surrounding interstellar and circumstellar medium (CSM); the CSM is especially important, since an X-ray detection or limit can be related to the nature of the putative companion – whether a giant star, solar-type star, etc. – since those objects can be expected to have blown material into the CSM over their lifetimes. If no detections are made (and as your piece notes, there has never been an X-ray detection for any previous type Ia SNe), the detection limits may provide evidence for a double-degenerate scenario where two white dwarfs have merged. It all depends on how tight those limits (or detections) are.”

“UV spectroscopy from Hubble will also help to prove the elemental composition of the fireball as it expands and becomes more transparent, allowing us to see `deeper’ and understand something of the fusion processes which took place when the progenitor detonated,” he told me. “And gamma-ray observations will help constrain the amount and distribution of nickel-56 in the ejecta, which will help us understand the nature of the WD structure and detonation mechanisms. It’s all very exciting!”

Satisfying your curiosity

SN94_M_infectionLatest science news in my fortnightly column for Spectroscopynow.com, now online:

Steroid infection: Steroids are often injected into sites along the spinal column in treating back pain, but if a batch is contaminated serious infection can arise. Researchers have demonstrated that magnetic resonance imaging (MRI) at the site of injection could be used to identify fungal spinal or paraspinal infection, allowing early pharmacological or surgical intervention to reduce the risk of serious complications. via Back to basics.

Mars – The bigger picture: Images recorded by NASA’s Curiosity Mars rover and sent back to Earth have been composited into what is the equivalent of a 1000 megapixel photograph of the surface of the Red Planet. The image offers armchair astronomers and others an opportunity to examine the Martian landscape in much greater detail than ever before. via The bigger picture.

Liquid colour: Researchers in Japan have used NMR spectroscopy to study liquid materials with excellent light stability based on the skeleton of the organic fluorescent dye anthracene that could be used for full-colour tuneable luminescent systems. via Tuneable colours.

Portable detection: The optical technique of surface-enhanced Raman scattering (SERS) has been used to detect signs of infection in tissue samples before patients even show symptoms of viral disease. The system could be further developed into a portable lab-on-a-chip (LoC) devices for use in the clinic with potential for applications in the developing world. via Portable infection: SERS detection.

Lip up: Fatty lipid molecules in the human body act not only as energy storage molecules and structural elements but are also important signalling compounds. Lipids with their head in a molecular cage have now been used to study such molecules and their roles in diseases such as atherosclerosis and diabetes. via Lip up: Fatty molecules investigated.

Fuel matters: Altering the crystalline structure of cellulose from its native form to another can lower its binding partition coefficient for fungal cellulose enzymes by 40-50% but surprisingly boost hydrolytic activity. This new finding could thus help open the road to more efficient enzymatic production of biofuels from biomass rather than petroleum. via Insights into enzymatic conversion.

Spectral lines

Dicarbonyl didact – NMR spectroscopy has been used to investigate dicarbonyl sugars formed inside the human body from the natural breakdown of the simple sugar, glucose. The implications for understanding the link with diabetes are discussed.

Biochemist Anthony Serianni and postdoctoral research associate, Wenhui Zhang,of the University of Notre Dame in Indiana, USA, are providing important new clues as to the nature of diabetes that one day might lead to novel treatments. Serianni explains that the biological compounds known as dicarbonyl sugars are produced inside the human body from the natural breakdown of the basic sugar compound, glucose. The formation of these sugars occurs to a greater extent in people with diabetes because glucose concentrations in the blood and plasma can be much higher than normal. More on Sweet complexity….

Brainy structure – Structural changes in the brain revealed by magnetic resonance imaging are tied to common gene variants linked to disorders such as Alzheimer’s disease, schizophrenia, and autism and can be observed in brain scans of newborn infants.

In research that was funded by the US National Institutes of Health, Rebecca Knickmeyer of the University of North Carolina School of Medicine and colleagues John Gilmore, Jiaping Wang, Hongtu Zhu, Xiujuan Geng, Sandra Woolson, Robert Hamer, Thomas Konneker, Weili Lin and Martin Styner, show how certain changes in the brain found in adults are associated with common gene variants present at birth. More on brain scanning and genetics….

Wall to wall antioxidants – Amino acid functionalised nanotubes scavenge free radicals faster than conventional synthetic antioxidants. Multi-walled carbon nanotubes functionalized by sonication with various amino acids can act as synthetic antioxidants. IR spectroscopy and other techniques have been used to study their effects and reveal these entities to be more potent than other synthetic agents in scavenging free radicals.

Ahm Amiri of the Department of Engineering at the Islamic Azad University, in Marvdasht, Iran, and colleagues Mina Memarpoor-Yazdi, Mehdi Shanbedi, Hossein Eshghi, writing in the Journal of Biomedical Materials Research A explain how they are keen to develop potent antioxidants able to scavenge free radicals. Free radicals are implicated in oxidative reactions involved in diabetes mellitus, certain forms of cancer and cardiovascular disease. More on antioxidant nanotubes.

Nobel Prize for Chemistry 2012

UPDATE: And the Prize goes to… The Royal Swedish Academy of Sciences has decided to award the Nobel Prize in Chemistry for 2012 to Robert J. Lefkowitz Howard Hughes Medical Institute and Duke University Medical Center, Durham, NC, USA and Brian K. Kobilka Stanford University School of Medicine, Stanford, CA, USA “for studies of G-protein—coupled receptors”. It’s bio but with huge pharma implications.

I’m pleased to note that I wrote about Kobilka’s work back in 2010 although when I pressed him to hint at implications of that particular study he was reluctant to give me such a hint. Unfortunately, I don’t remember writing about Lefkowitz in the last few years.

The press release is here.

The Nobel Prize in Chemistry for 2012 was announced today. I hadn’t noticed until now that the prize money for this year’s Nobels is down 20% on that given last year. According to CNN this is “due to the turbulence that has hit financial markets.”

Turbulence? That’s whorls and eddies in a fluid that leads to a bumpy ride on an aeroplane or a bit of seasickness if you’re going by boat. It’s bloody great icebergs that have hit financial markets these last few years, “not a bit of turbulence”. Chaos theory helps us come to terms with the unpredictability of the weather, of catastrophic collapse, of fractal growth, and even economics. What is it that makes politicians and bankers imagine that they can control global finances? Haven’t they heard of the butterfly effect…

Anyway, back to the Nobels…you can watch the live stream later this morning: