Needed() and changed() region function

Hello,
I'm studying the basicBoxBlur code that comes as sample in
PBToolkit. As I'm a beginner in code writing, I have some troubles
understanding properly the use of needed() and changed() region
function: are they supposed to simplify the PB calculations, since
the filter runs even commenting those lines?
Could you gently provide some more info about their role
specifically in the basicBoxBlur code?
I'm sorry if this appears as dummy question, but the my
personal learning curve is quite steep... (my actual goal is to be
able to rewrite some sort of Gaussian Blur, Maximum, Minimum and
Median Photoshop filters, so this is only a initial step toward
them - I'll be fighting with sorting algorithms later on :)
TIA,
Davide Barranca

Hi Davide,
I'm really glad you've asked this question. It's a very good
question. Region functions would be considered one of the more
confusing, topics with respect to Pixel Bender. Unfortunately, this
makes it difficult to explain in words, but we'll try anyway.
The region functions are the mechanism by which you indicate
to the product your running in (whether it's the toolkit,
Photoshop, or After Effects) how your filter affects the size of
the image. Currently, Flash does not support these functions in the
Pixel Bender source, but you do need to implement the same thing in
the supporting ActionScript code.
If you think about a blur or any other convolution type
filter, you end up sampling a certain window around the pixel in
order to get the output color. For instance, if you have a blur on
the X axis that's one pixel in radius, you end up sampling 3 pixels
for every output: one to the left, the pixel that's at the same
coordinate as the output pixel, and one to the right of that.
Simple. If you consider what happens at the edge of the image,
though, things get more complicated. If you processing the result
for the very left edge of the output image, say at coordinate
(0,0), you'll need to sample three pixels, (-1, 0), (0, 0), (1, 0).
You need to account for the negative values when sampling. There is
a similar problem on the other edge where you will be sampling at a
location greater than the output window on the right. This means
that to produce an output of size 512, you actually need an input
of size 514 (one extra pixel for the left, and one extra pixel for
the right). This is what the needed function is calculating. The
function answers the question: "For an output of size X, what size
input do I need?" In most cases this will be exactly the same as
the output, but in some examples, like BoxBlur, this is not the
case.
The same thing happens on the output as well. Consider the
one dimensional box blur with a radius of 1 again. In this case,
you provide it an input of size X. If we were interested in
displaying any pixels that had any color at all, we would get an
output of size X + 2. This is because the edge pixel contribute to
the coloring of pixels outside of the input dimensions. In other
words, we would get a non-black pixel at location (-1, 0) because
the pixel at (0, 0) would be within the radius. This is what gives
you a smearing of the image outside of its boundaries when you
apply a blur to it. This is what the changed function is
calculating. In other words, it asks the question: "If I give the
filter an input of size X, what sized output would it produce?"
Again, for most cases, this would be the same as the input
size. Filters that fall into this category are color corrections.
Additionally, for convolutions and blurs, the needed function would
be the same as the changed function. For warps and other
transformations, this is not the case. The best example of this is
scaling the image by two.
When you commented out the region functions, the output image
became smaller by the blur radius. This was probably not very
noticeable, but if you made the radius large, you would see the
difference. Additionally, you are probably asking why we need this
level of detail in the filter. In most simple examples, no one
would ever notice this since we often have a single input image and
execute a single filter on it. However, because these filters can
be used as a small part of the workflow for professional graphics
and effects applications, getting these details right is very
important for the filter to render the correct results in all
cases.
Since you asked specifically about the basicBoxBlur sample,
here's a breakdown. Note that the functions are exactly the same
code because it's a convolution.
float2 singlePixel = pixelSize(src);
This is getting the pixel aspect ratio. One thing I didn't
mention is the notion of the pixel aspect ratio and the need to
account for this when calculating the regions (this is the subject
of another post entirely).
return outset(outputRegion, float2(singlePixel.x *
ceil(blurRadius), singlePixel.y * ceil(blurRadius)));
The next line is increasing the requested region by the size
of the blur window radius (conceptually expand the single radius
out to a radius of size blurRadius). We take the ceiling of the
blur radius in case the radius is a non-integral value.
I hope that helps clear up any confusion. Please let me know
if you have any questions or need clarification on any points. By
the way, I'm very impressed with your list of filters, and I wish
you the best of luck with the sorting ones.
Thanks,
Brian Ronan

Similar Messages

  • I need to change region on itunes?

    i need to change region on itunes and i got a message that i have rented yet to expire. i need to know what was rented and how to move forward in the region changing

    I have the same problem. I moved back to Finland after 3 years in the US. Now I am trying to change the region settings on my iTunes and I get the message saying that I am not able to change the region because I have rentals that have not yet expired. As a matter in fact they have expired already several days ago. They do not even show on the iTunes when I connect my iPad (iOS 5.1.1)

  • Photosmart 2710 need to change region for printer cartridges

    Hi:
    I am an international resident currently residing in Brazil. My printer is programmed for Asian print cartridges and the region needs to be changed so I can purchase cartridges locally.
    When I changed from Europe to Asia, HP support in Singapore was very helpful and English speaking. Support in Brazil only speaks Portuguese and I need the instructions in English.
    Who can I contact for this, as I am out of warranty and the HP Website is a maze of unhelpfulness, if you are out of warranty.
    This question was solved.
    View Solution.

    You will need to Contact HP to request a "Regionalization Reset". There should not be any charge for this, it is covered as part of the cartridge warranty. You will need to have access to your computer and printer while on the line with HP. You will also need to have a set of cartridges for the new region, once the reset is complete cartridges from the original region will no longer work.  HP's web page on the subject is here.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • SuperDrive and changing region encoding

    I am going on a trip to New Zealand for a few months (business training) and am looking for a new laptop to take with. I am planning to take along DVDs I already own, but would like to be able to watch DVDs I pick up locally as well.
    I know that some drives can be swapped back and forth between regions a set number of times before they "stick" on one. My questions are:
    1) Can the Super Drive play DVDs from both region 1 (US) and region 4 (NZ, among other places)?
    2) If it needs to switch between them when I put one from region 1 and then region 4, is there a limit to the number of switches allowed?
    3) Is there software that can aid in this effort? (I realize that last question skirts the boundary of legality, and I am an attorney, so it needs to be legal.)
    Thanks in advance for any advice.

    I am considering switching my primary laptop to one of the new MacBook Airs but, as a frequent traveler, also need to find a region free DVD solution. This is for my personal use--nothing illegal--but the greater difficulty of getting around region settings on Macs (as compared to PCs) is one of the main factors that has kept me from making the leap.
    Any thoughts are appreciated.
    Thanks,
    Ben

  • Season Pass and changing Region

    I really need some help.
    I have recently immigrated from the UK to New Zealand, but I am unable to change the region in my iTunes store due to 2 season passes believed to be open.
    When I look at the available episodes, I do believe that all have been made avaiable on the iTunes Store, and that I have completely downloaded all episodes.
    I have been in contact with support, but the allways give me the same answer which effectively state that I have to wait for the season passes to complete.
    I have now been waiting 6 months. As I no longer live in the UK, I have no registered credit or debit cards avaiable to pay for new purchases. This leaves me unable to use the iTunes store.
    Any advice will be greatly appreciated!
    Etienne

    You will continue to receive the season pass, since you have already purchased, and paid the whole season.
    However, you will no longer be able to purchase new season pass, or any content from iTune store in Canada once you move to France, since iTunes restricts credit card/debit card purchases to home country address.
    However, you can still continue to purchase content from Canadian iTunes store, if you use iTunes gift card, and an address in Canada. (ask you relatives for the address). However, due to strict tax laws regarding how softwares are sold in Canada, you will not be able to purchase apps in the App Store section of iTunes with gift card (credit card/debit card or cash is the only accepted form of payment in purchasing software in Canada, since iTunes is e-commerce store, only credit card/debit card is accepted)

  • Need to change regions but without canceling my iTunes Match

    I recently moved back to the US but cannot change my region unless I cancel my iTunes Match subscription. What can I do? Please help!

    Hi,
    You need to contact Apple to cancel match. Read this doc https://discussions.apple.com/docs/DOC-5432
    Jim

  • Lost event and changed button functionality

    Iphoto crashed while I was writing comments about photos in an event. This was the second last event imported. On relaunching the event has been duplicated but both events are empty.
    The next strange thing happened when I reloaded the photos again. I now find that the buttons of the top, next to the line "1 photo selected" do not move from photo to photo as they used to but takes me to an adjacent event.
    Iphoto 9.4.1, OS x 10.7.5
    Any thoughts?
    Mike

    my mouse has 3 buttons and 2 axis mouse wheel, but i use the evdev driver anyway, because it has lower latency. I may probably switch to evdev for the keyboard too. evdev is a driver for usb devices.
    http://wiki.archlinux.org/index.php/Get … ns_Working
    Using evdev the wheel seems to work better.

  • I need to change my region from Canada to Argentine, but I have 19Cents on my account

    So here is the thing: I went to Canada last year for about a month and a friend of mine gave me a giftcard for about 25$, but I needed to change my region because of obvious facts. But now I am back in Argentine and I can not longer purchase things because my credit card adress is from my country, so I need to change regions but, as you may already know, one can't just simply change regions having money in his/her balance. I went to the applesupport page but there is not actual support for Argentine, what can I do?
    Please if you could help me I would be more than grateful.
    Thanks for reading

    Take a look at this link, http://www.apple.com/support/itunes/contact/

  • Changing region and purchases

    Hello! Now I'm in Russia and want to buy Logic Pro. After some time I leave country and going to live in the U.S. I will need to change region from Russia Federation to USA and update billing and payment information. Will I lose my Logic Pro purchase? It is quite expensive to buy again this app...
    Thanks!

    What do you mean will you loose it. Apple is not responsible to safeguard your apps. Apple constantly reminds folks to backup their apps and other purchased content. As long as you do not delete your app, it is safe.
    However, other users report that as long as the app in question is sold in the app store for your new country of residence, you should be able to update the app.

  • I have credit and it's less than 0.99 and i need to change the region and i don't have visa

    i have credit and it's less than 0.99 and i need to change the region and i don't have visa

    Click here and ask the iTunes Store staff to zero your account balance.
    (110223)

  • HT204406 Cancelation of my active iTunes Match subscription is not working and I urgently need to change my region.

    I have temporary relocated to the USA from the UK and I urgently need to change my region settings.  I have spent my remaining iTunes balance and cancel my auto renew to iTunes Match (as asked to do on my account page) but it isn't allowing me to change region.  The message that I have an active iTunes Match account keeps appearing. WHY?!?!?!

    Yes. They wouldn't say it if it wasn't true. System requirements are stated on the iPhone box and Apple website.
    Other alternative is to activate the phone on someone else's newer Mac OS X, but you'll still need iTunes to sync, backup, install etc.

  • HT5622 I have been using one apple ID for my family as it makes it easier to manage itunes purchases/rentals on all of our devices.  Now that my kids are getting old and my wife has recently purchased an Iphone, I can see that I need to change my strategy

    I have been using one apple ID for my family as it makes it easier to manage itunes purchases/rentals on all of our devices.  Now that my kids are getting old and my wife has recently purchased an Iphone, I can see that I need to change my strategy. I plan to add a few more iphones to the family very soon.  What is your recommendation to manage all of our devices (iphones, itouch, apple tv) for my family?  Can I continue to function with one apple ID or is it time to take the leep into attempting to manage multi-apple ID's? 

    There's a few ways of managing multiple devices on a single computer (and keeping seperate content on each). The following document is worth checking through:
    How to use multiple iPods, iPads, or iPhones with one computer

  • HT204266 my daughters appleid pops up on my phone when I go to update my apps. How does this happen and how can I change it.  It also states that I am in the US store when my id and country region are canadian.

    My daughter apple id pops up on my cell phone when I go to update my apps. As well I get this message that I am logged into the United States app store yet I am in Canada and my region is Canada in settings?  We share the same pc and so I am wondering how to avoid this problem and how I could change it back to my id and my region for the app store.

    you downloaded apps using her Apple ID which is set the the US Store.
    You need to delete all those apps from your phone and download them with your Apple ID

  • HT1918 I am trying to change the country of id on my apple store payment details.  The button does not bring up options, just resets itself.  I need to change the country as I have moved and payment is no longer valid, I can't download any new apps.  Help

    I am trying to change the country/ region on my store account.  When I press the 'change country/region' section in 'my account' it does nothing.... I have moved country, so I cannot enter valid details of payment and so the store is refusing all app requests.
    Has anyone a way around this please?

    Before you can change countries in iTunes, you will need to have a valid payment information addressed in Ireland. When you have one, you can go ahead and change the country on your account.
    - sign in to iTunes
    - go to Account Information page
    - enter your Apple Id and password
    - click on Change country or Region
    - enter your new information then save
    If you will have a hard time, I suggest contacting email support.
    https://expresslane.apple.com/GetproductgroupList.action

  • Creation and Change Date for Tcode and Function Groups

    Hello All,
    I need to display the Creation and Change Dates for Custom Tcodes and Function Groups in a Report. Can anyone please let me know the logic of retrieving it.
    regards,
    Mahesh

    Hi,
    TADIR and TRDIR is the tables where you can find all these data
    Regards
    Sudheer

Maybe you are looking for

  • Setting Up Menu Bars On Dual Displays

    My grandma recently upgraded computers and gave me her old 22" Chimei LCD monitor. I bought the DVI-D attachment and have the monitor hooked up to my Macbook. My question is.. is there a way (program, setting, etc.) to set up a menu bar on both scree

  • Canon Pixma MG7150 wifi connection problems

    We recently purchased a Canon Pixma MG7150 printer so that we could wirelessly connect to our windows 7 laptop, and all our apple devices.  We were able to set up the printer following the instructions and it worked no problem.  However, everytime we

  • Did anyone have this problem?Please Read

    Can anyone tell me if they had the problem that the screen froze with a song's info. You can still listen to songs but the screen DOES NOT change. I can even turn it off but the screen will not shut off. Does anyone know how to fix this??

  • How to queue movie files to play after each other?

    Hi, I have home movies that I want to watch continually. I'm sick and tired of clicking on each file and playing it. I'd like to queue a selection of movies and just let them run one after another. HOW do I do this? Help please!! Thanks, Chris.

  • I can't open the iBooks after I downloaded an article. How do I solve this?

    My iBooks start giving me problem after I downloaded an article. Think it could be due to the article but can't delete it since I can't open ibooks