Custom Image Filter

Hello,
I want to create my own image filter. This filter should look for each pixel
whether the red/blue/green-pixel-value is below 25 and if so set the alpha-vlaue to 0.
I want to make those pixel translucent.
I found some samples of custom filters but I am not familar with the shift operators ( < / << / ... )
So any ideas or tutorials?
Regards,
Olek
Edited by: 848710 on 30.03.2011 13:15

Olek,
The hex values in my sample program serve two different purposes. In this part
a = 0xF0;
r = 0xE0;
g = 0xC0;
b = 0x80;they are the actual values for alpha, red, green, and blue. I always use hex for that because it is easy to figure out how to add another 25% here (0x40) or another 12.5% there (0x20). I chose those four values because they were distinct, easy to recognize after being packed and then unpacked, and all were guaranteed to sign-extend if treated as bytes. You are quite correct that hex values like these get used in other settings, like CSS, to specify colors. Because each pair of hex digits represents a distinct byte, it's a very simple way to specify a color in a single hex number. In my example, that number would just be 0xE0C080 (or, if you included the alpha channel, 0xF0E0C080).
Now, when it is necessary to strip off (people often say "mask") the bits you don't want from a packed four-byte integer, the hex numbers are serving a different purpose. When you use the AND operator (the "&" character), it actually operates at the level of the individual binary digits (the "bits") to produce a result. Suppose we want to get just the green value from the packed integer in my example. The integer is 0xF0E0C080. In binary, that's this:
11110000111000001100000010000000To get the green part, you need to shift these bits eight places to the right, with ">> 8." That gives you this result:
11111111111100001110000011000000A number of interesting features appear in that result. First, notice that the eight bits on the right end of the original number are gone. They get lost as a result of the shift operation. The right-most 24 bits of the result are exactly the same as the original left-most 24 bits of the number before the shift operation. That's literally what "shift" does: it moves the bits. But, most interestingly of all (perhaps) are the left-most eight bits of the result. Notice they are all "1" bits. That's because the right-shift operator (the ">>") sign-extends its result. The effect is that a negative number produces a negative result. In Java, this is always how the right-shift operator works. In other languages, including C, it's not always specified. Some C compilers will sign-extend right-shifted negative numbers, and some won't. It's up to the compiler writers to decide. In Java, it's not up to the compiler writers. The ">>" always sign-extends. Whether or not right-shifts should extend signs has been known to keep some programmers arguing for hours and hours. These types of debates are called "religious" arguments, which usually means they are not worth having. As I am a Unitarian Universalist, and my church has taken no position on sign-extension in right-shifts, I don't care one way or the other. To avoid needing to know, however, I always just use a mask to get only the bits I want, which I will explain in a second. (But, you should know, Java includes an unsigned right-shift operator, ">>>," so you have final say in your own code as to whether there will be sign-extension or not.) All of this comes from the fact that Java, C, and most languages represent signed integers with "two's-complement" arithmetic, which is a kind of numerical magic you don't want to have learn much about if you don't have to.
Now, we wanted the green byte, right? It started out packed into our four-byte integer as the ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, and sixteenth bits, starting with the first bit as the one on the right. By shifting our integer eight bits to the right, our green byte is now in the first, second, third, fourth, fifth, sixth, seventh, and eighth bits. (Beware that most people number bits the same way that you use an array index, by calling the first one "bit zero," the second one "bit one," and so on). In my code, I masked off the bits I didn't want, and kept the bits I did want, with one of those hex values: 0xFF. The operation was this:
g = (i >> 8) & 0xFF;To understand what that does, you need again to see it in binary. The "i >> 8" part results in the 32 bits I wrote out above. The "0xFF" part is another 32-bit number, the first 24 of which are all "0," and the last eight of which are all "1" (Java conveniently treats hard-coded constants like integers, so 0xFF is treated like a 32-bit number, the same as if we had written "0x000000FF"). So, in binary, i >> 8 and 0xFF look like this:
11111111111100001110000011000000
00000000000000000000000011111111Finally, the AND operator works on the matching bits in the two values above. That is, the left-most bit of each is matched with the left-most bit of the other, the second left-most bit is matched with the other's second left-most bit, and so on. For each matched pair of bits, if one of the bits is "1" and the other bit is "1," the matching bit in the result is "1." In any other case, the result is "0." So, "(i >> 8) & 0xFF" results in this:
00000000000000000000000011000000In hex, that's "0xC0," which is our green value, which is what we wanted.
So, in some cases, my hex values were providing actual numbers, to set the values of alpha and the color channels. In other cases, they are serving as masks, to get rid of the bits I don't want and leave behind only the ones I do want, after shifting, to unpack those alpha and color values when I have them in packed form.
Hope that helps.

Similar Messages

  • Reduce size of custom images in Address Book

    I love Address Book's wonderful integration with Mail.app, my iPod and even my phone. So, one day I decided to set custom images for almost all of my contacts - copying and pasting images into the fields.
    However, afterwards, I realised that my 275 contact address book has ballooned from 2MB to 49.9MB thanks to the pictures. If I export the contacts into a Group vCards, it is an astounding 121.8 MB.
    I feel that Apple should've limited the size of the pictures (automatically resize it just as iPhoto does for email and iWeb does for the web). However, this isn't the case.
    Thus, my question is:
    Is there a script or anything to reduce the size of those custom images? I am not looking forward to deleting the pictures and resizing them before importing them into Address Book. If there is an automated way of resizing the pictures, please let me know!
    Thank you very much!

    Hi mintchocicecream,
    Have a look at this:
    http://discussions.apple.com/message.jspa?messageID=2271577#2271577
    May be of no help, but sounds like you have larger that necessary files.
    I do mot know of any script, short of a photoshop group resize that would work. Certainly nothing in Address Book.
    Good Luck
    John

  • Custom Image bullets--is there a way to change the color?

    The reason why is I'm trying to use one of the circles and it keeps coming out dark gray, and it needs to be white (on a B&W laser printer). This is for a check list on a church bulletin.
    Also, is there a way to upload other bullet images to use?
    Thanks!
    MacBook Pro 15", CoreDuo 2 2.33 ghz   Mac OS X (10.4.9)   Cube 450 mhz

    You would need to edit the custom image in some other application, such as GraphicConverter.
    As for your second issue, Custom Image is the way to set an arbitrary image as a bullet -- what do you mean by "upload"?

  • How do I use a custom image as a bullet in Keynote 09?

    All I need to do is use a PNG file as a bullet in the Master
    Everything I find online says there is a Custom Image option but the only choices I see are None, Bullet, Image, Lettered, Numbered.
    This should be simple but I have already wasted 2 hours trying to do this.
    Please, can someone tell me what I am missing? What am I not understanding about this procedure?

    As stated, the problem was that I could not find Custom Image anywhere.  I finally figured out that along with the drop down menu for the Bullets there is also a triangle before the word Bullet 7 Lists. THAT is where one finds the Custom Image choices

  • Loading custom image formats

    Hello all.
    I am wanting to load a custom image format into my Java application, and am wondering how to do that. I have a few ideas to try but I figure if there is a site out there (or someone with the knowledge), there is no need for me to re-invent the wheel. So hopefully, someone might be able to expedite my learning. :)
    The image format I want to read actually contains multiple images, with 1 color palette at the end of the file. I'd like to create a series of (I assume) BufferedImages for all the images contained within the file.
    Are there any sites out there that can send me through a quick tutorial on rolling my own images, or can anyone give me a short function to do so?
    Thanks so much!

    Okay... I failed. I could really use some help in getting this work. Please.
    I have a file, which contains 1 or more compressed bitmap images and a palette. I have a small Perl script that will convert the images in the file into multiple bitmap image files, so I know where the data is and I know I have the data locations right. :)
    To create a BITMAP, I must reverse the order of the palette (perl function):
    sub reversePalette() {
      my $output = "";
      for (my $i=0; $i < length($_[0]); $i=$i+4) {
        $output = $output . substr($_[0], $i+2, 1) . substr($_[0], $i+1, 1) . substr($_[0], $i+0, 1) . chr(0);
      return $output;
    }For the image data itself, it uses a simple RLE encoding. If I see a 0, I check the next number and "uncompress" the data by adding that many 0's to the output file.
    So, what I would like to do is convert my Perl script into a Java class that will take this sprite file and return an array of BufferedImages, which can then be used for whatever.
    Any help in this would be greatly appreciated! I can't even figure out how to properly load a valid BMP file manually using WritableRaster and ColorModel. I'm so lost. :(

  • How to use custom images in Apex 4.1 with EPG

    I just ported over an application from Apex 3.2/10g using Apache to a new server using Apex 4.1/11g using EPG and none of my custom images work. When using Apache, all I had to do was copy the file over to the /i/Custom images folder and I could reference it on any of my pages. I copied the entire /Custom folder to the new server and that doesn't seem to do the trick. I've seen some posts that talk about having to use FTP (why?) or something to get this to work. Can someone please explain what is going on here and what I need to do to get this working?

    With EPG, the images aren't accessed from a directory. They are actually stored inside the database. The FTP process actually gets redirected so that the image gets stored inside Oracle rather than being written to a file. There are numerous articles and such detailing exactly how to do this.
    One is here:
    http://www.apex-blog.com/oracle-apex/accessing-i-using-ftp-170.html

  • Custom image from Address book not syncing to Exchange.

    I am running Mac OS X v 10.7.5. I have added custom images to contacts in address book. I have an Exchange account which will sync the data (ie name, address, email) but not the custom image. Is there away to have custom images sync to Exchange/Outlook?

    I'm Running Mac OS X Lion, and have seen that changes made in the mac address book do not sync to gmail contacts but changes to gmail contacts do sync to the mac address book.
    Making a change to a contact on my phone does sync to gmail contacts, and then to the mac address book.
    Another test I ran was to change the same contact in gmail and mac address book.  I made a change to a mobile number and notes in one contact on my mac address book, attempted to sync, and the change does not appear in my gmail contacts.  I tried multiple times, restarted my web browser, restarted mac address book, the sync would not work.  I changed the same contact mobile number in gmail with a slightly different change to the notes field so I could see when an update occurred, and when I told mac address book to sync it recognized a conflict. When I select the mac address book change to resolve the conflict, the gmail contact is not updated.  When I repeated the experiment and selected the gmail contact to resolve the conflict the change is made in the mac address book.

  • Custom images all jumbled in Address book

    I have about 4000 contacts in my address book. Some of them had custom images (photo) attached. I sync my Mac, .Mac, and iPhone routinely.
    One day, my Address Book decided to jumble up all the photos. Not nice. Is there a way to delete all my custom images from my address listings? I know how to do it individually, but there are too many to delete that way.

    It appears that there is a major bug in this new version of Address Book. First I found that when you go in the "Print" panel, go to "Envelopes", go to "Layout", and then go in Layout to "Layout" submenu and use "Define Custom" which comes up "Layout Name" and when type in any name and click "OK" it UN-SELECTS the "Layout Panel" and you cannot change any of the parameters, BUT I discovered that if after you type in a "Layout Name", click "OK": and then click "Cancel" and then again open "Print". It opens to the same place as before (with everything the same) BUT with the Layout Panel SELECTED and you can now change all the parameters. I don't know about the printer printing blank sheets, because my printer seems to work fine. But I have a HP and you have an Epson. Hopefully those geniuses at Apple will get around to fixing this problem sometime in 2006 or 2007, who knows!!!!!

  • Adding custom image to scorecard

    Experts,
    I'm trying for the last 2 days to add a custom image to a custom view of BIEE 11g Scorecard but failed....
    How should I direct the image ?
    is it 'fmap:/images/....' ?
    I'll appriciate any help
    Thanks fwd,
    Roy

    Hi,
    Check this for 10g...http://bintelligencegroup.wordpress.com/2010/09/06/add-custom-images-to-dashboard/
    Not sure about 11g,but check for the images folder.Might be in style folder.If so you can do it in the same way as we do in 10g.
    Regards,
    Srikanth

  • Adding a Custom Image to a Style

    Yet another dumb question! Is it possible to add a customized image to a style? For example, I have a style named Caution and I want this style to use a specific image. If this is possible, please provide details for implementing it. If it is not possible, perhaps a snippet is the better option?
    Thanks again.

    Willam:
    Thanks for the offer. One of the issues I have encountered is that the url for the image changes and then the image no longer appears. For example, I specify url("Note.png") and when I save the css the path is updated to url("../../Note.png"). Also, as I discussed previously, the formatting for multi-line entries is a bit wonky:
    It would be nice to have the text alligned to the left.
    Here is how the entry currently appears for this style:
    p.Note {
          margin-right: 0.000pt;
          text-align: left;
          margin-bottom: 9.000pt;
          word-spacing: 0.250em;
          font-family: Arial;
          font-style: normal;
          font-weight: normal;
          color: #000000;
          letter-spacing: 0.00em;
          font-size: 11pt;
          text-indent: 0.4in;
          margin-left: 0.4in;
          x-next-class: Body;
          x-next-type: p;
          margin-top: 9pt;
          background: url("Note.png") no-repeat left top;
          padding-left: 25px;
          margin-left: 18pt;
          line-height: 33pt;text-decoration: none;
    Message was edited by: Captiv8r - Corrected Willam's name - again

  • Custom image in search control appears blurred in IE10

    hi,
    We are facing a unique issue of few users seeing blurred image for the search icon in the search  control. if the user clears the cache, it appears correctly but he susequently comes back to search page, it again blurs.
    We had replaced the default image with custom image.

    hi Inderjeet,
    Please find my replies inline below
    Do we have BLOB cache enabled. 
    [SRao] no
    Does other browsers works fine
    [SRao] yes
    Does all the users face same issue
    [SRao] yes. Even for this user it works fine few times. We tried zeroing down to the network level but still it keeps poping up everynow and then.
    Can you check what happens when we use Fiddler tool
    [SRao] Fiddler shows all well. we get http 200 ok when access the url of the image.

  • Sap/bw/Mime/Customer/Images Path in SAP BW Server

    Hi,
    while developing the Web Reports, Our consultants has used some logos in the templates in the development server. These logos are appearing in development properly. I have transported these templates to the quality where these icons are not displaying.
    Post that I found these icons are picked up from from the location  '/sap/bw/Mime/Customer/Images/headjetlogo.gif'. I am trying to copy these files from development to quality. But I am unable to find this path on development server.
    Can anyone please help  me on how do I find these files.
    Thanks
    Ramesh Ganji

    hi Ramesh,
    when we attach the file to dev, system will ask for 'local object' or specify package and save to request to be transported.
    since it's not 'insert' by you, try right click in SE80 and check if there is 'object directory entry', change the package and it will prompt request or right click the file and find menu 'export' or 'download', it will then save to you local pc (specify a folder).
    after that go to production, se80, right click the folder and 'import mime objects' from the file downloaded.
    hope this helps.

  • Can't add Custom Image to Contact Card

    Just upgraded to Snow Leopard. Noticed that when making up a new contact card, I can't just drop an image (somebody's face) into the Custom Image box anymore. The box lights up -- highlighted in blue -- but it won't accept the image. Any ideas?

    Similarly, I'm on 10.6.2. Since Snow Leopard came out, I have been unable to add/edit any "Custom Images" in my Address Book entries. Everyone in my AB is stuck with the image they had in my Leopard Address Book. Looks like there's several threads on this, but no great (i.e. Apple-fixed0 solution I've seen so far.
    What does work for me now is:
    1. going to the Finder,
    2. select the Address Book application (make sure the app isn't running),
    3. Get Info
    4. Select the "Open in 32-bit mode" checkbox
    5. Open the Address Book app, and begin editing images
    http://discussions.apple.com/thread.jspa?messageID=10732789
    http://discussions.apple.com/thread.jspa?threadID=2135020&tstart=120

  • Custom images in Oracle BI

    I needed to add the custom images in my BI dashboard and followed the same guidance provided on OTN threads to add the images in the 3 diffrent directory locations in my 11g setup. After Adding it to the 3 different path I restarted my presentation services. Now when i go to my conditional formatting tab and i provide the path in custom image field as fmap:images/myimage.jpg and say ok I see the image in the conditional formatting tab. But then i dont see the image on my dashboard. So the problem is the image is comin up in the conditional formatting window but not on actual dashboard. I tried clearing the browser cache and temporary internet files but still no use.

    Hi,
    the proplem with you image size only, let try it exsting oracle bi default image it will work keep it the same size of your image and the place it corresponding folder then restart your all bi sevices
    Refer this link: i*t's obiee10g try the same method in obiee11g..it should work*
    http://gerardnico.com/wiki/dat/obiee/fmap
    http://oraclebizint.wordpress.com/2007/09/27/oracle-bi-ee-101332-changing-logos-in-the-answers-title-view/
    http://addsrikanth.wordpress.com/2008/06/10/displaying-images-in-obiee/
    if its not working above method please
    Make sure below thinks
    In Ideal situation Oracle can accept on that image which is already present in Oracle BI. But if you want to add new picture then first you have to change instanceconfig.xml file which is present in BIData\web\config. and add the following line
    <HardenXSS>false</HardenXSS>
    that they have given in Presnetation services Administrative tool guide.
    and now add the desireable picture in image folder that is
    BIHome\web\app\res\s_oracle10\images
    And
    BIHome\oc4j_bi\j2ee\home\applications\analytics\analytics\res\s_oracle10\images
    check which is suitable.
    Now use fmap: for adding picture.
    Restart all the services related to BI. all are not needed but I dont know which one so restart all.
    Now I think you can get the Answer
    It should work
    THnaks
    Deva
    Edited by: Devarasu on Sep 21, 2011 1:21 AM

  • Where is the Pan Image filter

    I need to use the Pan Image Effect on a great set of still images and can't find the Pan Image filter. I should have been able to find it under video transforms folder on the Effects Palette.

    I was able to make the pan effect work. It is really poor when compared to stage tools.
    1) the image pixelation is rediculous
    2) the finished result is worse than  rediculous
    3) I took the stage tools and did a horizontal pan at the bottom of the image that would be equalent to about isa small strip along the botton 8000x6200 image at about a scale of600 during the entire process the entire full resolution image was on screen and the little frame moved across the image and the pop up monitor that was provided by stage tools showed the actual path of the frame across that full size image (30" monitor) so you not only saw it in high resolution but it was extremely easy to track especially when following a non irregular line down a winding canyon or river.
    the reason that the stage tools client list reads like the who's who's of motion picture industry is because it's about 100 times better than using the motion effect built into Adobe.
    http://www.videofame.com/VideoProductions/Client_List_Broadcast.mht
    did you really think that Lucas Films would have been one of the largest users of this plugin if Adobe had the panning capability this does.
    You guys are like trying to think that anything you can't do Adobe directly is silly. Give it a break. I love Adobe I own I think the fact that they encourage outside vendors to create great plugins for Adobe users is brilliant. some how I think you guys have missed the point. Adobe can't even compare with stage tools for panning and zooming. like a difference between a VW bug and a F1 Ferrari it's just rediculous. But don't take my word for it download the stage tools for free like I did and try it. You just won't believe the difference. You need to start with a super quality image though from the Hasselblad website downloads area you should be able to download some 50 or 60 MB files that are like the dimensions shown below:
    http://www.hasselbladusa.com/products/h-system/h4d-60.aspx
    Sensor size: Dalsa 60.1 Mpixels (8956 x 6708 pixels)
    Sensor dimensions: 40.2 mm x 53.7 mm
    Image size: RAW 3FR capture 80 MB on average. TIFF 8 bit: 180 MB
    Where talking Lucas film quality now not 35mm Rebel or D30's

Maybe you are looking for

  • Unable to Check ADD Attachment Check Box. Thereby getting only email and not the attachment (which will contain the output of BO report , in Excel Format)

    Post Author: hteoh CA Forum: Publishing I have an BO related issue. I tried to schedule a smtp event in BO to email the report output as Excel. Since this report will go to different users, I unchecked the Use the Job Server's defaults (CHECK BOX). F

  • Restoring Entire System with Time Capsule

    Hello, I configured my Time Capsule with custom user accounts (AirPort Utility -> Disks -> File Sharing -> Secure Shared Disks: with Accounts). I think this may be causing a problem with selecting a backup source for an entire system restore to a re-

  • Indesign Printer Drivers

    I'm unsure if this is the correct place for this question, but let me throw it out there and maybey someone will have an answer. I'm trying (on a wing and a prayer) to get some kind of color management going. I have a color printer and it was (hastfu

  • Item renderer issue

    Hi, I have a comboBox as item renderer in my datagrid (comboBox item renderer code bellow). 1. How can I remove the first blank item? My comboBox arrayCollection doesn't have 0 item. 2. If I come back to the cell that it was already selected with a v

  • Volume changes up and down during all solng

    Every time I listen to songs, the volume goes up and down and up and down again.. Anyone know why - and more important, how to fix it? Thanx..Anne