From mboxrd@z Thu Jan 1 00:00:00 1970 Mime-Version: 1.0 (Apple Message framework v752.3) In-Reply-To: References: <15e34c88856214df634907d08dfc8aa1@coraid.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <12E38AC1-E684-4679-8CCE-5B6342338BD0@telus.net> Content-Transfer-Encoding: 7bit From: Paul Lalonde Subject: Re: [9fans] code inspection needed/appreciated Date: Mon, 2 Apr 2007 08:39:40 -0700 To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Topicbox-Message-UUID: 3c308b1e-ead2-11e9-9d60-3106f5b1d025 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 From someone who pushes pixels every day: You almost certainly don't want a pixel-processing framework that breaks things down to pixels! Most interesting operations on images require a neighbourhood of pixels, or even whole-image information. Furthermore, even for those manipulations that don't, a function call per pixel is a huge amount of overhead. Since you mention doing this as a framework, I can only imagine that the compiler wouldn't even get to inline the per-pixel function, making speedy execution impossible. With real-sized images being in the greater than 2kx3k range these days, you're looking at *a lot* of function calls. Instead, I'd advise you look at a channel-based representation: break up RGBA into 4 larger buffers and pass those to your "doSomethingWithImage" function. The addressing requirements are simple and it's easy to address sub-images (call the total width "pitch", and pass that separately from your current "tile" width). And the compiler will have a much easier time unrolling your loops! Paul On 2-Apr-07, at 1:29 AM, wrote: > It is intended to be a general 'template' for operations on single > pixel, like, e.g., rotation in RGB-space. It should jump the pixels > and feed its RGB(A) values to the function doSomethingWithPixel(). > I would like to (re)write some image manipulation functions, like > color balance, gamma, ... > from NetPBM, and from elsewhere, to native 9 code working on 9 images. > I suffer from being a self-made-man in computing, and of course, > from a lack of spare time, as everybody today. Although I did some > APE&native ports of my favourite programs, I love plan 9 so much > that I want to rewrite some of them in a clean way. > I have much to do with digital imaging, either at work, or as a > hobby. I must e3mphasize here that I dont like the paradigm of > 'applications' -- user intensive programs, so I'd like to follow > the UNIX/Plan9 paradigm of well-tuned single-purpose programs > working together glued via a rc script, if I got it right. > Thus, any helping hand ismuch appreciated. Hopefully, one day I'll > do rm -fr /n/linux, as i did it with Windoze several years ago. > > Back to the question: for the time being, the 'rgb.c' program, > after defining the 'do Something...() function to do nothing, > should write exactly the same image out, as was the one on the input. > > Thanks for your care, > have a great day, > > ++pac. > > > > -----Original Message----- > From: 9fans-bounces+cej=gli.cas.cz@cse.psu.edu on behalf of erik > quanstrom > Sent: Fri 3/30/2007 3:44 PM > To: 9fans@cse.psu.edu > Subject: Re: [9fans] code inspection needed/appreciated > > could you please explain this code a bit futher. i'm not sure i > understand > what it's supposed to do and how it would be used. > > - erik > >> Hello all! >> >> >> >> I have put a simple code that is intended to manipulate individual >> RGB pixels, on: >> >> /n/sources/contrib/pac/sys/src/cmd/img/rgb.c >> >> If anyone has time and is willing to help me, I would appreciate >> inspecting the code and telling me your comments!! >> >> Thank you, >> >> have a great weekend, > > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Darwin) iD8DBQFGESO8pJeHo/Fbu1wRAnuWAJ42N/vVCK18KwDJRReXlJqCAaKieQCfT+oU kPbGUyB6lizaknGZ9B1LEgE= =fClE -----END PGP SIGNATURE-----