Continued probs with hi-quality downsampling of hi-res photos
As you may know, I’ve been trying for a year to find a way of doing high-quality downsampling of hi-res photos using Jitter. The goal is being able to downsample a source photo of up to 4k x 4k (or cropped subset thereof) with high-quality interpolation in Jitter. The most manageable solution seemed to be using jit.lcd. Alas, even the simplest attempt at putting this into an iterative process bombs after about 1.5 hours. Please see the attached simplified file (just iterating a load of jit.matrix that then feeds jit.lcd) with notes included. Any help is greatly appreciated!
——related approaches to the same problem——–
Joshua mentioned a while back about the possibility of exposing high-quality interpolation right in the jit.matrix. Any chance of progress on this? ;)
There have been several other solutions offered:
1. averaging downsample: doesn’t provide high-enough quality
2. JS Image class using fromnmedmatrix() and tonamedmatrix(): this worked on Max 4.5.x but broke on 4.6. Joshua apparently spent a bunch of time trying to work this out in 4.6 but never resolved.
3. "make clever use of jit.convolve to perform arbitrary filters": no clue how to approach this :(
4. use external app like ImageMagick to do the heavy lifting: I’ve implemented this on a Mac PPC using mxj.syscommand (unsupported) but that object doesn’t appear to run on Intel Mac. Anybody know another way of communicating with Mac system on Intel?
5. prescale the images in Photoshop: doesn’t fulfill the project design spec… must be on the fly.
6. Use Java libraries: unfortunately over my head
7. new dimscale feature of jit.gl.slab and jit.gl.imageunit: can’t get to work
Any help or suggestions? I’m getting desperate!
On Feb 8, 2007, at 9:43 PM, Jeff Burger wrote:
> 7. new dimscale feature of jit.gl.slab and jit.gl.imageunit: can’t
> get to work
Check out example I posted in this thread. Make it downsample instead
Thanks, Joshua. Unfortunately, this solution doesn’t appear to work with anything close to hi-res source images… not even 1080 HD. Here’s what I get when I set the dims on the jit.qt.movie to 1920 x 1080:
>error: jit.gl.pbuffer: error binding invalid pbuffer!
>error: jit.gl.texture: error binding readback mechanism for capture!
>jit.gl.texture: error submitting texture data: GL Error: Invalid value
(This is on a Mac G5 2.5GHz dual with 2.5GB RAM and stock Radeon 9600 XT.)
Since I’m only importing hi-res still photos, I tried modifying your routine by replacing jit.qt.movie with jit.matrix and clocking the matrix. (Using jit.matrix also gives the benefit of reading in a photo of unknown dims, where jit.qt.movie appears to need to know the exact dims in advance in order to get best quality?) The jit.matrix approach seems to work fine with source photos up through 1080 HD. A test with 2400 x 1568 source photo yielded distorion, though. And a test at 3000 x 2008 gives me:
>jit.gl.texture: error submitting texture data: GL error: invalid value
>jit.gl.texture: setting subtexture during submission: GL error: invalid operation
Again, while my original attempts included accepting images up to about 6000 x 4000, I’ve scaled this expectation back about as far as I can to the 4096 x 4096 max that I perceive the OpenGL routines work with.
BTW, I realized after I sent the original message that the attachment wasn’t zipped and perhaps didn’t come through intact. I’ve zipped and reattached here. Note that assuming we get jit.lcd solution to iterate without crashing, the down side to jit.lcd for me is that apparently I can’t (at least easily) specify the dims of jit.lcd on the fly.
Where do we go from here? There’s got to be some manageable solution to this in the Jitter bag o’ tricks somewhere! Your help is very much appreciated!
On Feb 9, 2007, at 11:40 AM, Jeff Burger wrote:
> Thanks, Joshua. Unfortunately, this solution doesn’t appear to work
> with anything close to hi-res source images… not even 1080 HD.
> Here’s what I get when I set the dims on the jit.qt.movie to 1920 x
>> error: jit.gl.pbuffer: error binding invalid pbuffer!
>> error: jit.gl.texture: error binding readback mechanism for capture!
>> jit.gl.texture: error submitting texture data: GL Error: Invalid
> (This is on a Mac G5 2.5GHz dual with 2.5GB RAM and stock Radeon
> 9600 XT.)
This is most likely a limitation of your graphics card. With a Radeon
9600 2656×2656 is the maximum resolution you can use (note my patch
*doubles* size rather than halves it. so 1080 should work if you
tweak the figures to halve.)
However using the high quality software renderer you should be able
to work at up to 16k x 16k resolutions (on Apple only, sorry PC
users, you’ll need to get tweaky with MESA for better software
rendering). Simple rework of my gaussian upsampling example patch at
bottom. Play with the filter width to have softer/sharper filtering
> Since I’m only importing hi-res still photos, I tried modifying
> your routine by replacing jit.qt.movie with jit.matrix and clocking
> the matrix. (Using jit.matrix also gives the benefit of reading in
> a photo of unknown dims, where jit.qt.movie appears to need to know
> the exact dims in advance in order to get best quality?)
Could use jit.qt.movie @movie_dim 1 to automatically adapt to the
loaded image/movie size.
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 641 155 17 196617 0.;
#P message 603 155 31 196617 0.25;
#P message 579 155 14 196617 1;
#P message 548 155 20 196617 8.;
#P button 152 157 15 0;
#P user jit.pwindow 481 431 322 242 0 0 0 0 1 0;
#P newex 482 401 129 196617 jit.matrix 4 char 320 240;
#P newex 200 216 86 196617 jit.gl.texture foo;
#P user jit.pwindow 90 431 322 242 0 0 0 0 1 0;
#P newex 91 407 146 196617 jit.matrix foo 4 char 320 240;
#P flonum 580 184 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 580 263 90 196617 param width 0 $1;
#P newex 200 293 364 196617 jit.gl.slab foo @file cf.gaussian.2p.jxs
@dimscale 1. 0.25 @param width 0. 0.5;
#P message 553 222 90 196617 param width $1 0;
#P newex 200 259 361 196617 jit.gl.slab foo @file cf.gaussian.2p.jxs
@dimscale 0.25 1. @param width 0.5 0;
#P comment 646 194 88 196617 filter width;
#P newex 200 327 195 196617 jit.gl.videoplane foo @transform_reset 2;
#P message 200 115 274 196617 read http://www.blueeyes.jp/eyes/
DSCN5802.JPG , bang;
#P newex 200 152 111 196617 jit.qt.movie 1280 960;
#P user jit.fpsgui 113 224 60 196617 0;
#P number 136 112 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 91 112 15 0;
#P newex 91 138 55 196617 qmetro 20;
#P newex 91 173 55 196617 t b b erase;
#P newex 91 377 133 196617 jit.gl.render foo @quality 1;
#P window setfont "Sans Serif" 20.;
#P comment 81 42 698 196628 1280 x 960 downsampling to 320 x 240 with
apple software renderer;
#P connect 4 0 3 0;
#P connect 21 0 2 0;
#P connect 3 0 2 0;
#P connect 2 0 1 0;
#P fasten 2 2 1 0 140 206 96 206;
#P connect 1 0 16 0;
#P connect 16 0 17 0;
#P connect 2 1 6 0;
#P connect 5 0 3 1;
#P connect 15 0 21 0;
#P fasten 8 0 7 0 205 140 205 140;
#P connect 7 0 18 0;
#P connect 2 1 18 0;
#P connect 18 0 11 0;
#P fasten 12 0 11 0 558 248 205 248;
#P fasten 14 0 13 0 585 285 205 285;
#P connect 11 0 13 0;
#P connect 13 0 9 0;
#P connect 7 0 19 0;
#P connect 19 0 20 0;
#P connect 15 0 12 0;
#P connect 25 0 15 0;
#P connect 23 0 15 0;
#P connect 22 0 15 0;
#P connect 24 0 15 0;
#P connect 15 0 14 0;
#P window clipboard copycount 26;
Feels like we’re getting close!… but I’m still having problems with your last post. (For anybody else reading, you need to remove the space before the last part of the provided URL for starters.)
On G5 w/ Radeon 9600XT, I get images in pwindows and filter control. The processed image doesn’t seem noticably sharper to me. Could have something to do with the stream of error messages Max is spitting out?:
>error: jit.gl.readback: unable to create framebuffer: pbuffers not supported!!
>error: jit.gl.readback: error initializing framebuffer: framebuffer objects not supported
>error: jit.gl.texture: error creating readback mechanism for capture!
So I decided to try it on new MacBook Pro 17" w/ 2MB RAM and Radeon X1600 w/ 256MB VRAM. Yielded imagery again along with variations on the error messages:
> error: jit.gl.pbuffer: error binding invalid pbuffer!
> error: jit.gl.texture: error binding readback mechanism for capture!
Are these message a concern?
Can you explain what aspect of this routine forces software rendering?
Not sure I understand when you say your patch doubles size rather than halves it?
Can you point to or list your gaussian upsampling patch you refer to?
Re your suggestions of jit.qt.movie @movie_dim 1, Max tells me:
>jit.qt.movie: "movie_dim" is not a valid attribute arguement.
Finally, your comments about graphics cards cause me to look for an upgrade on my G5. What qualifications am I looking for to take advantage of GPU and OpenGL manipulation of at least 4k x 4k? AGP 8X? 256MB? Radeon 9600 Pro (PC & Mac Edition w/ 256MB?)
Thanks SO much! :)
On Feb 9, 2007, at 4:09 PM, Jeff Burger wrote:
> On G5 w/ Radeon 9600XT, I get images in pwindows and filter
> control. The processed image doesn’t seem noticably sharper to me.
It should not be sharper. It should be blurrier. This is what anti-
aliasing does in *any* application. You can control the blurriness by
changing the filter width. A sinc or mitchell filter would be sharper
than a gaussian, but can introduce "ringing". There are many types of
filter functions and different tradeoffs. Apple’s lcd uses a "lanczos-
sinc" filter when downscaling.
For more info on different filters, I’ll need to direct you to online
> Are these message a concern?
Hmmm. Try upgrading to 10.4.8 if you haven’t already, and perhaps
latest jitter beta. I"m not seeing these errors with the latest
Jitter Beta on 10.4.8 (search forum archives)
> Can you explain what aspect of this routine forces software rendering?
Using a jit.matrix object as the rendering target. Please read the
Tutorials for more info.
> Not sure I understand when you say your patch doubles size rather
> than halves it?
Previous post I sent, the one I just sent actually quarters the size.
> Can you point to or list your gaussian upsampling patch you refer to?
> Re your suggestions of jit.qt.movie @movie_dim 1, Max tells me:
>> jit.qt.movie: "movie_dim" is not a valid attribute arguement.
Sorry, movie_dim is the gettable movie dimensions. I meant @adapt 1.
> Finally, your comments about graphics cards cause me to look for an
> upgrade on my G5. What qualifications am I looking for to take
> advantage of GPU and OpenGL manipulation of at least 4k x 4k? AGP
> 8X? 256MB? Radeon 9600 Pro (PC & Mac Edition w/ 256MB?)
I’d recommend an NVidia 6800 or ATI X800 of one variant or another if
you can spring for them. The GT or more affordable versions if you
can find them should be fine. I’d just recommend you stay away from
NVidia 5xxx series or ATi 9xxx series.
All the specs for 4096×4096 textures and render destinations
(required for slab processing) are listed on the previous link (check
out the ppc one and look at the max viewport and texture rect sizes).
Here’s the PPC version of that page I sent in case it wasn’t obvious:
xlr8yourmac.com is a good resource to find out more about the
different mac graphics cards available for your setup. For example:
Hope this is enough info for you to go on since I’ll need to drop out
of the discussion at this point.
Thank you for your feedback, Joshua. It took me a while to locate a graphics card with the right specs, but between that and the upgrade to the latest Jitter beta, I seem to be in much better shape now!