Avoid blurring when doing imrotate; or apply a histogram #17

Closed
DarrenCook opened this Issue Aug 15, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@DarrenCook

(feature request)

When I use imrotate, on a 28x28 pixel, greyscale image (actually MNIST data), it ends up more blurred. I.e. when I plot the before and after histogram, the after image has slightly lower peaks at the black and white extremes, and all the much smaller grey peaks in the middle have got a bit higher.

If I do 12 rotations of 30 degrees, I get a blurry blob. The ideal would be no information loss at all and to get back the exact pixels I started with. (I tried all three values for interpolation: 1 is more blurry, 2 is better, and 0 gives a weird "pulled apart" result.)

(BTW, I used crop.borders(after , nPix = (width(after)-width(before))/2) to sort out the size problem.)

Using imsharpen() after imrotate() was not successful.

IDEA 1: Be able to apply the histogram of another image, and it will brighten or dim pixels until it matches. I don't know how to write this, but the usage would be: after <- imApplyHisogram(after, before)

IDEA 2: Could there be a version of imrotate() that didn't change the image size, and didn't blur? (It feels like the fact that the image grows in size is related to the dilution of image brightness?)

P.S. I'm happy to provide test data, and my test rotation scripts, if there is interest.

@dahtah

This comment has been minimized.

Show comment
Hide comment
@dahtah

dahtah Aug 17, 2016

Owner

Rotation without blurring is hard, I wouldn't be surprised if people
still are writing papers about it. I'm kicking that one upstairs, to see
if the author of CImg has a good solution for you.
To remove useless dark space, have you tried autocrop?

For histogram matching, is that what you need?

#Give a the histogram of b
match.hist <- function(a,b)
     {
         if (spectrum(a) != spectrum(b))
             {
                 stop("a and b should be both colour or both grayscale")
             }
         else if (spectrum(a) == 1)
             {
                 quantile(b,probs=rank(a)/nPix(a)) %>% as.cimg(dim=dim(a))
             }
         else
             {
                 for (cc in 1:spectrum(a))
                     {
                         channel(a,cc) <- 
match.hist(channel(a,cc),channel(b,cc))
                     }
                 a
             }
     }

match.hist(boats,load.example("parrots")) %>% plot
match.hist(load.example("parrots"),boats) %>% plot

Le 15/08/2016 22:46, Darren Cook a écrit :

(feature request)

When I use imrotate, on a 28x28 pixel, greyscale image (actually MNIST
data https://www.google.co.uk/search?q=MNIST+data&tbm=isch), it ends
up more blurred. I.e. when I plot the before and after histogram, the
after image has slightly lower peaks at the black and white extremes,
and all the much smaller grey peaks in the middle have got a bit higher.

If I do 12 rotations of 30 degrees, I get a blurry blob. The ideal
would be no information loss at all and to get back the exact pixels I
started with. (I tried all three values for |interpolation|: 1 is more
blurry, 2 is better, and 0 gives a weird "pulled apart" result.)

(BTW, I used |crop.borders(after , nPix =
(width(after)-width(before))/2)| to sort out the size problem.)

Using |imsharpen()| after |imrotate()| was not successful.

IDEA 1: Be able to apply the histogram of another image, and it will
brighten or dim pixels until it matches. I don't know how to write
this, but the usage would be: |after <- imApplyHisogram(after, before)|

IDEA 2: Could there be a version of imrotate() that didn't change the
image size, and didn't blur? (It feels like the fact that the image
grows in size is related to the dilution of image brightness?)

P.S. I'm happy to provide test data, and my test rotation scripts, if
there is interest.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#17, or mute the thread
https://github.com/notifications/unsubscribe-auth/ADEJEJVvTJd4QdC1Ouew6BJxgMe7t-VHks5qgNAvgaJpZM4JkwS6.

Owner

dahtah commented Aug 17, 2016

Rotation without blurring is hard, I wouldn't be surprised if people
still are writing papers about it. I'm kicking that one upstairs, to see
if the author of CImg has a good solution for you.
To remove useless dark space, have you tried autocrop?

For histogram matching, is that what you need?

#Give a the histogram of b
match.hist <- function(a,b)
     {
         if (spectrum(a) != spectrum(b))
             {
                 stop("a and b should be both colour or both grayscale")
             }
         else if (spectrum(a) == 1)
             {
                 quantile(b,probs=rank(a)/nPix(a)) %>% as.cimg(dim=dim(a))
             }
         else
             {
                 for (cc in 1:spectrum(a))
                     {
                         channel(a,cc) <- 
match.hist(channel(a,cc),channel(b,cc))
                     }
                 a
             }
     }

match.hist(boats,load.example("parrots")) %>% plot
match.hist(load.example("parrots"),boats) %>% plot

Le 15/08/2016 22:46, Darren Cook a écrit :

(feature request)

When I use imrotate, on a 28x28 pixel, greyscale image (actually MNIST
data https://www.google.co.uk/search?q=MNIST+data&tbm=isch), it ends
up more blurred. I.e. when I plot the before and after histogram, the
after image has slightly lower peaks at the black and white extremes,
and all the much smaller grey peaks in the middle have got a bit higher.

If I do 12 rotations of 30 degrees, I get a blurry blob. The ideal
would be no information loss at all and to get back the exact pixels I
started with. (I tried all three values for |interpolation|: 1 is more
blurry, 2 is better, and 0 gives a weird "pulled apart" result.)

(BTW, I used |crop.borders(after , nPix =
(width(after)-width(before))/2)| to sort out the size problem.)

Using |imsharpen()| after |imrotate()| was not successful.

IDEA 1: Be able to apply the histogram of another image, and it will
brighten or dim pixels until it matches. I don't know how to write
this, but the usage would be: |after <- imApplyHisogram(after, before)|

IDEA 2: Could there be a version of imrotate() that didn't change the
image size, and didn't blur? (It feels like the fact that the image
grows in size is related to the dilution of image brightness?)

P.S. I'm happy to provide test data, and my test rotation scripts, if
there is interest.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#17, or mute the thread
https://github.com/notifications/unsubscribe-auth/ADEJEJVvTJd4QdC1Ouew6BJxgMe7t-VHks5qgNAvgaJpZM4JkwS6.

@DarrenCook

This comment has been minimized.

Show comment
Hide comment
@DarrenCook

DarrenCook Aug 17, 2016

Your match.hist() worked well! Here is an example:

rotate_then_match_histogram

However when I rotate 12 times, 30 degrees, it corrupts the image in an interesting way!

rotate_with_match_hist

For comparison, here is the the same loop without the histogram adjustment:

rotate_without

I also tried running the histogram adjustment, just once after all rotations:
rotate_then_match_hist_at_end

(I'll post code in the next comment.)

Your match.hist() worked well! Here is an example:

rotate_then_match_histogram

However when I rotate 12 times, 30 degrees, it corrupts the image in an interesting way!

rotate_with_match_hist

For comparison, here is the the same loop without the histogram adjustment:

rotate_without

I also tried running the histogram adjustment, just once after all rotations:
rotate_then_match_hist_at_end

(I'll post code in the next comment.)

@DarrenCook

This comment has been minimized.

Show comment
Hide comment
@DarrenCook

DarrenCook Aug 17, 2016

The code for the previous comment

#Prepare a test digit
library(imager)
m <- structure(c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L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, 0L, 0L, 
22L, 70L, 0L, 0L, 0L, 149L, 135L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 175L, 
213L, 0L, 0L, 12L, 237L, 136L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 12L, 232L, 149L, 
0L, 0L, 17L, 254L, 131L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 125L, 245L, 24L, 
0L, 0L, 54L, 254L, 50L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 24L, 228L, 174L, 0L, 0L, 
35L, 173L, 254L, 187L, 150L, 128L, 101L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 124L, 254L, 144L, 
121L, 202L, 248L, 254L, 245L, 207L, 89L, 85L, 67L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 227L, 254L, 
254L, 245L, 137L, 122L, 254L, 105L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 200L, 190L, 
123L, 24L, 0L, 89L, 240L, 10L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 184L, 224L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 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0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L), .Dim = c(28L, 28L))
im = as.cimg(m, x=28, y=28)

#Try rotate, then match.hist
im2 = imrotate(im, 15);nPix = (width(im2)-width(im))/2;im2 = crop.borders(im2 , nPix = nPix)
im3 = match.hist(im2, im)
par(mfrow=c(2,3))
plot(im);plot(im2);plot(im3)
hist(im);hist(im2);hist(im3)

#Rotate 30 degrees at a time, matching histogram after each one.
par(mfrow=c(2,6))
im4 = im
plot(im4)
for(n in 1:11){
  im4 = imrotate(im4, 30);nPix = (width(im4)-width(im))/2;im4 = crop.borders(im4 , nPix = nPix)
  im4 = match.hist(im4, im)
  plot(im4)
  }

#The same, but without matching histogram
par(mfrow=c(2,6))
im4 = im
plot(im4)
for(n in 1:11){
  im4 = imrotate(im4, 30);nPix = (width(im4)-width(im))/2;im4 = crop.borders(im4 , nPix = nPix)
  plot(im4)
  }

#Same rotations, but just match histograms, once, at the end
im5 = im
for(n in 1:12){
  im5 = imrotate(im5, 30);nPix = (width(im5)-width(im))/2;im5 = crop.borders(im5 , nPix = nPix)
}
par(mfrow=c(1,3))
plot(im)
plot(im5)
im5 = match.hist(im5, im)
plot(im5)

The code for the previous comment

#Prepare a test digit
library(imager)
m <- structure(c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L,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L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 219L, 71L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 46L, 254L, 17L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 46L, 
206L, 3L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 37L, 136L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L), .Dim = c(28L, 28L))
im = as.cimg(m, x=28, y=28)

#Try rotate, then match.hist
im2 = imrotate(im, 15);nPix = (width(im2)-width(im))/2;im2 = crop.borders(im2 , nPix = nPix)
im3 = match.hist(im2, im)
par(mfrow=c(2,3))
plot(im);plot(im2);plot(im3)
hist(im);hist(im2);hist(im3)

#Rotate 30 degrees at a time, matching histogram after each one.
par(mfrow=c(2,6))
im4 = im
plot(im4)
for(n in 1:11){
  im4 = imrotate(im4, 30);nPix = (width(im4)-width(im))/2;im4 = crop.borders(im4 , nPix = nPix)
  im4 = match.hist(im4, im)
  plot(im4)
  }

#The same, but without matching histogram
par(mfrow=c(2,6))
im4 = im
plot(im4)
for(n in 1:11){
  im4 = imrotate(im4, 30);nPix = (width(im4)-width(im))/2;im4 = crop.borders(im4 , nPix = nPix)
  plot(im4)
  }

#Same rotations, but just match histograms, once, at the end
im5 = im
for(n in 1:12){
  im5 = imrotate(im5, 30);nPix = (width(im5)-width(im))/2;im5 = crop.borders(im5 , nPix = nPix)
}
par(mfrow=c(1,3))
plot(im)
plot(im5)
im5 = match.hist(im5, im)
plot(im5)

@dahtah dahtah closed this Aug 31, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment