Filmulator half pixel offset bug rambling/discussion

I discovered an interesting bug the other day and just want to kinda document it here in the hopes of getting myself to fix it this weekend.

Filmulator uses Qt Quick for the user interface which offers a lovely graphics accelerated user interface with smooth animations and fully scalable UI elements.

One of the fun things is that I was able to simply put the output of the photo processing pipeline as an Image on a Flickable item, and that instantly gives the image smooth panning characteristics. Placing the image on an intervening viewport-sized rectangle let me keep it centered when the image is smaller than the viewport. Otherwise, it sticks to the top left corner of the Flickable.

This is all fine and dandy for most circumstances because when you view a scaled image that just fits in or is smaller than the viewport, it doesn’t matter the exact pixel alignment of the photo.

However, I was investigating the small dot pattern edge artifacts that LMMSE produces in lieu of color moire, when I noticed that they weren’t visible in 1:1 scaling in Filmulator, but they were visible if I zoomed in farther, as well as when I output a jpeg.

It turns out that the image in question was a vertical image from my GR, which on my 4k screen is less wide than the Filmulator viewport. So by being placed in the horizontal center of the rectangle, it was being shown halfway between pixels, averaging away the moire.

So what I’ll have to do is to detect when the image is both at 1:1 and is smaller in either direction than the viewport, and the viewport and nudge it half a pixel off center from the rectangle, though I believe it must only be applied when the widths of the viewport and the image are neither both even nor both odd.

I just thought that it was interesting… A bug only I would notice, only with a high resolution screen and a not so high resolution camera, in portrait orientation, with mismatched even/odd widths, while scrutinizing the demosaicing.

1 Like

I finally got around to fixing this.

Turns out that the math that computed the dimension of the background rectangle was yielding non integers somehow, and applying a floor function fixed that.

Even when the even/odd parity doesn’t match, as long as both the image and the background dimensions are integers, the image gets perfectly pixel aligned.