![]() |
Forum Index : Microcontroller and PC projects : "Advanced" Image Processing on CMM2
Page 1 of 2 ![]() ![]() |
|||||
Author | Message | ||||
RetroJoe![]() Senior Member ![]() Joined: 06/08/2020 Location: CanadaPosts: 290 |
I've been working a bit lately with HTML5 and CSS3, and was wondering if there is a possibility of implementing some simple 2D and 3D transformations on the CMM2 e.g. as CSUBs in MMBasic? The only built-in capabilities I can find along these lines is stretching an image and rotating it around a fixed point, but I'm thinking of stuff like skewing, warping, flipping an image along an axis in "3D" (e.g. to create a book page flip effect) or "tweening" between two images (e.g. for simple animation). The CIPS (C Image Processing System, PDF here) looks like a promising place to start. Is this idea feasible, and has anyone had similar thoughts? Would a GPU be necessary, and if not, is the STM32H7 fast enough to do "simple" stuff like this entirely in software? Cheers, Joe P. Edited 2020-10-01 03:27 by RetroJoe Enjoy Every Sandwich / Joe P. |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4044 |
The MATH functions should help. John |
||||
RetroJoe![]() Senior Member ![]() Joined: 06/08/2020 Location: CanadaPosts: 290 |
Thanks, John. I believe you are suggesting using MATH’s speed-optimized linear algebra to apply a transformation (more accurately, “deformation”) matrix to a bitmap stored in an array. I’ve ruled out using MATH’s built-in quaternion* rotate functions - while these do operate on vertices in 3-space, as far as I can tell the planes that form between them can only be filled with solid colors e.g. via the POLYGON command per the rotating Bucky Ball demos. My goal is to perspective-skew actual images. If this is the basic idea, do you know of a method to bulk load image pixels into an array (e.g. something equivalent to “BLIT2ARRAY”)? I guess traversing page memory with PEEKs inside a loop would be the default option. * my browser’s spelling checker has a REALLY hard time with “quaternion”!! Two surprisingly good suggestions were “quantum ion” and “quarter inch”. Edited 2020-10-01 22:49 by RetroJoe Enjoy Every Sandwich / Joe P. |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4044 |
If the MATH ones can't be shoved into doing it, maybe some new MATH ones would. If you could define the needed behaviour you could try asking for the actual functions. Otherwise I suppose use quite slow BASIC to get things going and convert the slow bits to CSUBs. John |
||||
RetroJoe![]() Senior Member ![]() Joined: 06/08/2020 Location: CanadaPosts: 290 |
Thanks again, and “funny you should mention that” - I’m not sure what I need yet :) I have to coin a phrase to describe what I’m experiencing, but it’s a real “first world problem”, something like trying to find a how-to article on building a transistor from scratch, in an era when a billion transistors on a chip costs a dollar. The state of the art in computer graphics is similar - it’s so “encapsulated” and freely available now that a Google search for “page flip effect” brings up a million articles on using HTML/CSS/JS, Blender, After Effects, Photoshop et al, and next-to-zero articles on the actual computational theory behind it. That CIPS document is the closest I’ve come so far to finding a primer on basic algos for computer imaging, and there are few other promising avenues (e.g. “OpenCV” in the Python realm). But, you have definitely pointed me in the right direction - just about everything I’ve read thus far involves heavy matrix operations, so the MATH functions should do the trick, and/or MMBasic array manipulation should be fast enough for my intended use case. If not, it should make me brave enough to try my hand at coding a CSUB! Cheers, Joe P. Enjoy Every Sandwich / Joe P. |
||||
RetroJoe![]() Senior Member ![]() Joined: 06/08/2020 Location: CanadaPosts: 290 |
I’ve got it - you’ve heard of “future shock”? What I’ve got is “retro shock” !! Edited 2020-10-02 00:21 by RetroJoe Enjoy Every Sandwich / Joe P. |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
If you develop any new generic image processing mechanisms I'm happy to build them into the IMAGE command as new sub commands. You would need to try and keep the UI concept similar though |
||||
RetroJoe![]() Senior Member ![]() Joined: 06/08/2020 Location: CanadaPosts: 290 |
Excellent news, Peter - thanks for the extra motivation :) I’m happy to report that after I posted my last comment, I realized I had boxed myself into a “modern modality” of expecting Google to provide All The Answers To Everything. Putting myself into “retro mode”, it dawned on me that Computer Science textbooks written a long time ago would have all the answers I was seeking. Sure enough, I almost immediately hit upon an excellent one, “Mathematics for Computer Graphics Applications” by Michael E. Mortenson, first published in 1989. I also still have my college textbook on linear algebra, which evidently I will need to dust off :) Edited 2020-10-02 02:09 by RetroJoe Enjoy Every Sandwich / Joe P. |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
"Funny you should say that." said vegipete just before being buried by an avalanche of old textbooks and papers he had precariously stacked around his computer station. Visit Vegipete's *Mite Library for cool programs. |
||||
PeteCotton![]() Guru ![]() Joined: 13/08/2020 Location: CanadaPosts: 543 |
It must be a canadian thing.... I have a bunch of old graphics text books from the 80's/90s as well.... ![]() Edited 2020-10-02 03:16 by PeteCotton |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Excellent, we're sharing shelfies now: ![]() The effect is somewhat spoilt by all my wire-bound BBC micro books. Cheers, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
PeteCotton![]() Guru ![]() Joined: 13/08/2020 Location: CanadaPosts: 543 |
Ha ha! I think it's a fascinating insight into our groups souls/minds. I'm not sure how many people would hang on to such a collection of old relics. Certainly, my wife (who is also a programmer) doesn't understand why I keep them. I suspect most of my friends don't give that shelf in my house a second glance. Yet here on the internet we've managed to find like minded individuals who share the same passion. If I was in your house I would be cracking open some of those books (especially the ZX Spectrum ULA one - that sounds fascinating). |
||||
Womble![]() Senior Member ![]() Joined: 09/07/2020 Location: United KingdomPosts: 267 |
The is a reason I'm known as The Womble ... I have bookshelves like that, indeed I see some volumes that can also be found in my collected "wombleage". ![]() |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
That one is quite recent and proved to be rather beyond my hardware understanding. I believe it's documentation of the same "research" that made the Harlequin ZX Spectrum clone possible. For full disclosure many of those books are recent (re)acquisitions related to my very geeky midlife crisis and a reaction to 20+ years of working with tens of thousands of lines of god forsaken Java and C++. Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
CircuitGizmos![]() Guru ![]() Joined: 08/09/2011 Location: United StatesPosts: 1427 |
Middle of changing my space chaos shelfie: ![]() Micromites and Maximites! - Beginning Maximite |
||||
Womble![]() Senior Member ![]() Joined: 09/07/2020 Location: United KingdomPosts: 267 |
The Graphics Gems Series are a very good resource for this type of code. Also Michael Abrash's Power Graphics Programming (1989) is also very good, this was later reworked into Graphics Programming Black Book (1997), I have the earlier volume. These links might be useful: Gems and Dr Dobbs/Abrash - Black Book I still have some of these books which I bought back in the early 1990s, along with my Computer Science university texts from the same time period. |
||||
Womble![]() Senior Member ![]() Joined: 09/07/2020 Location: United KingdomPosts: 267 |
@CircuitGizmos Thats some serious deforestation pictured there ![]() |
||||
PeteCotton![]() Guru ![]() Joined: 13/08/2020 Location: CanadaPosts: 543 |
Absolutely fantastic! These links might be useful: Gems and Dr Dobbs/Abrash - Black Book I still have some of these books which I bought back in the early 1990s, along with my Computer Science university texts from the same time period. Thanks! I think I have one of the early Graphics Gems books, but I don't think I ever got a chance to get into it. Yeah, I'm never letting go of my Uni textbooks. They cost me an arm and a leg back when I could barely afford student beer. I couldn't handle just discarding them. Edited 2020-10-02 07:36 by PeteCotton |
||||
RetroJoe![]() Senior Member ![]() Joined: 06/08/2020 Location: CanadaPosts: 290 |
@Gizmo....... you win :) I will show your "shelfie" to my wife, just to give her a sense for how "bad" it *could* be :) I'm almost too embarrassed to post mine now, but here goes... ![]() P.S. That "Code Complete" by Steve McConnell changed my life (the Anthony Robbins one, not so much :) P.P.S. Thanks for all the tips on CG math books, folks - the dam has broken (and the fog is lifting). I don't think it will be too hard, and FYI, this is the type of stuff I'm looking to implement on the CMM2 (the parameter values are editable, BTW). Again, if anyone knows a way to "blit" or "fast load" RGB pixel values directly into an MMBasic array, I would be much obliged! Joe P. In Montreal with Bookshelf Envy Edited 2020-10-02 08:33 by RetroJoe Enjoy Every Sandwich / Joe P. |
||||
jirsoft![]() Guru ![]() Joined: 18/09/2020 Location: Czech RepublicPosts: 533 |
For many graphics transformations will be helpfull, if at least BLIT command has more parameters: x1, x2, w1, h1 ... source x2, y2, w2, h2 ... target Then you can do some resizing and basic rotation (when axis are in the middle of source image part)... JirSoft Jiri Napoleon Commander and SimplEd for CMM2 (GitHub), Â CMM2.fun |
||||
Page 1 of 2 ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |