CompuServe Thread

#Help! Buggy macro

8 messages in this thread
#86372From: Charles BlaquiereJul 15, 1994 11:28 PM
Ben, I've created a wondrous macro to perform automated background removal on a series of images. The user just samples the background color to be keyed out, and away it goes, creating one anti-aliased alpha mask after another. Unfortunately, it has a bug which I can't solve. I tried it with a few images of an ampersand on a green background. When processing the first frame, the macro asks the user to sample the background; I circle some green. The macro then proceeds, using "color key max merge", to replace all non-green areas (the ampersand) with a black background; then, it replaces the green areas with white, using "color key MIN merge". A bit of fudging around, and the alpha channel is ready to be saved. No problemo. The bug occurs on all remaining frames: I only wanted the user to sample the background on the first frame, and it seems that Imagemaster loses track of the defined key color after frame 1 has been processed. Oh, I did try and have the AREXX macro save the 'cdef' red/green/blue/avg/var values on frame 1, and impose them on Imagemaster by using 'colchange' as indicated by your tech support person, but to no avail. Even though my RGB key color is 0,255,0 on frame 1, by the time all frames have been processed, manually clicking on any color key operation shows the key color has been changed to 0,100,0 — a far cry from pure green. As a result, all frames except the first one get improperly processed. I uploaded the REXX script, along with two tiny files needed for its use. All 3 files are to be stored in RXPI: and have been uploaded as BLUESC.RX, WHITE.24, and BLACK.24. Would you mind taking a look? I've got a real gem of a macro, a friend needs it pronto, and I'm one step away from making it work. Won't you help? Thanks. Blaq!
#86373From: Charles BlaquiereJul 15, 1994 11:31 PM
Oops — the version I uploaded has most image processing functions disabled, to save debugging time. The only operation left is "fill all non-key color areas with black", which turns the ampersand black, leaving the green background untouched. When frame 2 rolls along, the improper key color (altered by Imagemaster from 0,255,0 to 0,100,0) causes the _entire_ image to be filled with black.
#86394From: Black Belt SystemsJul 16, 1994 4:25 PM
ok, got it –Ben …via AutoPilot
#86393From: Black Belt SystemsJul 16, 1994 4:25 PM
I'll get the file an dhand it off to technical support on monday. Likely they'll be able to locate the problem. _however_, my guess is that it's a bug, from your description you're doing the things I would have thought to do, anyway. Hopefully we can work around it. –Ben …via AutoPilot
#86418From: Charles BlaquiereJul 17, 1994 3:05 PM
Ben, umm, nevermind. B^) There were actually two bugs, and I solved them on my own. 1) After the user selects an area, I do a 'cdef' to get color values for that region. However, those values will be _lost_ when the macro ends, and there's no way the _next_ invocation of the macro, on the next frame, will be able to tell Imagemaster to use those same colors. (As my T-shirt says, "I can't even THINK straight" — in this case, I wasn't even thinking, period) I solved the problem by using 'setclip' and 'getclip' to store color values in the first run, and reload them in subsequent frames. Once I gave Imagemaster's 'colchange' the right color values, it worked fine. <shrug> 2) Even with the right color values, the second frame would be totally replaced by black, green background and all. That's because… the background color on frame 2 wasn't the same. (How stupid of me) Once I altered all my test frames so they'd have compatible backgrounds, the macro worked just fine. So there you have it. I'll add a few more niceties to the macro, such as a variable edge fuzziness control, and upload it when it's done. Should make a nice addition to the stable of Imagemaster ARexx macros out there. Just think, someone on the Mac must be charging big bucks for this very thing. Don't you love working on the Amiga? Charles -via Fingers!
#86502From: Black Belt SystemsJul 19, 1994 12:54 AM
Charles, Glad you got it all going – your phone call this morning caught Dave just as he was reading your message of yesterday to me… :^) –Ben …via AutoPilot
#86626From: Peter GreciJul 20, 1994 12:15 PM
Can't wait to see yer script BLAQ!
#86615From: Peter GreciJul 20, 1994 11:20 AM
Maybe ya should try using the REDO function in yer Rexx Script BLAQ!?