Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

1) Removing the periodical grid 2) summing/folding to 1 dimension 3) corner case bug? #278

Unanswered
Nakilon asked this question in Q&A
Discussion options

I have some 1 band image. it is periodically (step=8) brighter in rows and cols. I want to suppress this periodical trait to remove the "grid". How do I do it in the most perfomant way?

I thought I should start with summing by rows and cols. I tried to do it by resizing but for some reason I've got values of -1 -- is it ok or is it some corner case bug?

irb(main):062:0> t.resize(1r/t.width, vscale: 1).to_a.take(10)
=> [[[-1]], [[-1]], [[-1]], [[-1]], [[-1]], [[-1]], [[-1]], [[1]], [[1]], [[-1]]]
irb(main):064:0> t.resize(1, vscale: 1r/t.height).to_a[0].take(10)
=> [[-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1]]

UPD: I suppose I've found a proper method:

irb(main):066:0> t.shrinkv(t.height).to_a[0].take(10)
=> [[0], [0], [0], [0], [0], [0], [0], [0], [0], [0]]
irb(main):069:0> t.shrinkh(t.width).to_a.take(10)
=> [[[0]], [[0]], [[0]], [[0]], [[0]], [[0]], [[0]], [[1]], [[1]], [[0]]]

I wish there was a fast method to do the opposite. resize back to original size (to then subtract/divide/whatever) seems to be slow.

You must be logged in to vote

Replies: 2 comments 2 replies

Comment options

Or actually maybe the really proper method to collapse the image to a row/column is vips_project.
Anyway, I've switched from that project for now.

You must be logged in to vote
2 replies
Comment options

Sorry @Nakilon, I was in a flat panic 18 days ago on a deadline and I must have forgotten to come back to this. I'll have a look now.

Comment options

No worries. That was a pretty blind experimenting about making metrics out of images and jpeg compression was the thing I wanted to fight. But I've got other metrics and decided to not dig here further for now.

Comment options

You can use shrink and zoom to do very fast integer scaling.

y = x.shrink(10, 1)

y will be 10x smaller horizontally and each column is the average of the 10 pixels in the input. zoom does the inverse:

y = x.zoom(10, 1)

Now y is 10x larger and each column in the output is repeated 10 times.

Perhaps I don't understand the problem exactly though -- post a sample image if I've misunderstood.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /