Skip to content

Histogram equalization for color images#28

Merged
martinber merged 10 commits intomasterfrom
unknown repository
Sep 17, 2020
Merged

Histogram equalization for color images#28
martinber merged 10 commits intomasterfrom
unknown repository

Conversation

@ghost
Copy link

@ghost ghost commented Aug 22, 2020

This changes the logic of the processing for color images when histogram equalization is selected:

  • perform 98% contrast adjustment
  • colorize image
  • histogram equalization

Everything else should remain the same.

I'm converting the image to Lab, equalizing the histogram for the L value [0..100], and then converting back to RGBA.

Here is the difference between telemetry / histogram with false color

Large image warning: 6MB

telemetry-vs-historgam

@ghost ghost changed the title Histogram equalization color Histogram equalization for color images Aug 22, 2020
@ghost
Copy link
Author

ghost commented Aug 24, 2020

I've finally managed to make the histogram equalization work "in-place", without copying channels around.
This is more in line with the "processing pipeline" without all the re-assignments (let img = do_something(&img)).

I should have marked this as draft when I started, in case you started reviewing it and I still made some changes, sorry about that.

One thing to be aware of are the unsafe blocks in histogram equalization. It's the same algorithm used in imageproc::contrast::equalize_histogram_mut src, but adapted to work with sub-images, as accessing the pixels is done differently.

Equalizing the histogram for the L channel happens in a similar way, but in range [0..100], so vector length is 101.

Please let me know if you have any suggestions or concerns, thanks!

After running `cargo audit`, it turns out `imageproc` crate has a known vulnerability:
https://rustsec.org/advisories/RUSTSEC-2020-0023

Also, we're no longer using anything from this crate.
If we need something in the future, keep an eye on this pull request that
seems to solve the issue by swapping the vulnerable dependency in imageproc
with another crate:
image-rs/imageproc#417

Details:

```
$cargo audit

error: Vulnerable crates found!

ID:       RUSTSEC-2020-0023
Crate:    rulinalg
Version:  0.4.2
Date:     2020-02-11
URL:      https://rustsec.org/advisories/RUSTSEC-2020-0023
Title:    Lifetime boundary for `raw_slice` and `raw_slice_mut` are incorrect
Solution:  No safe upgrade is available!
Dependency tree:
rulinalg 0.4.2
└── imageproc 0.21.0
    └── noaa-apt 1.2.0
```
Copy link
Owner

@martinber martinber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK the way it is, these are some suggestions that I will do if I find time

@martinber
Copy link
Owner

Very nice work. Sorry for taking so long. I will be very busy at least another week

@ghost
Copy link
Author

ghost commented Sep 5, 2020

Sorry for taking so long. I will be very busy at least another week

No worries! I've addressed all the issues, thanks for taking the time to look at this!

@martinber martinber merged commit b3733c4 into martinber:master Sep 17, 2020
@martinber
Copy link
Owner

Looks good!

@ghost ghost deleted the histogram-equalization-color branch September 18, 2020 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant