Average filter but the image is gray and not color RGB

Hi,
i use this code for an average filter 3x3, the result is the image whit average but gray and not RGB color.... why??
thanks in advance
    public void Average()
        int values[]=null;
        int input2d[] = new int [image.getWidth()*image.getHeight()];
        int [][] output2d=new int [image.getWidth()][image.getHeight()];
        image.getRaster().getSamples(0, 0, image.getWidth(), image.getHeight(),0,input2d);
        for(int y=0; y < image.getHeight(); y++)
            for(int x=0; x < image.getWidth(); x++)
                int count = 0;
                int average=0;
          values = new int[5*5];
                for(int s = 0; s < 5; s++)
                    for(int r = 0; r < 5; r++)
                        try
                            values[count] = input2d[(y-2+r)*image.getWidth()+(x-2+s)];
                            count++;
                        catch(ArrayIndexOutOfBoundsException e){ }
                //trovo il valore medio dell'intorno 5x5
                for (int temp=0; temp<count; temp++)
                    average+=values[temp];
                int valpixel=average/count;
                output2d[x][y]=valpixel;
        image2 = new BufferedImage(image.getWidth(),image.getHeight(), BufferedImage.TYPE_INT_RGB);
        image2.getGraphics().drawImage(image,0,0,null);
        for(int y=0; y < image.getHeight(); y++)
            for(int x=0; x < image.getWidth(); x++)
                image2.getRaster().setSample(x, y, 0, output2d[x][y] );// componente R
                image2.getRaster().setSample(x, y, 1, output2d[x][y] );// componente G
                image2.getRaster().setSample(x, y, 2, output2d[x][y] );// componente B
    }

Can hel me please!!!

Similar Messages

  • When using Firefox certain videos play but the image is green and distorted.. help?

    Firefox 3.6.8 and 3.5 (I downgraded to see if that would solve the issue)
    Windows 7
    Intel Core i5
    Flash Player: WIN 10,1,53,64
    When using Firefox certain videos play but the image is green and distorted. The image turns into lines and sometimes it half of the screen of the video. Examples are streaming MLB.tv video and some vimeo videos. The odd thing is that it isn’t all Vimeo videos. Is this a flash issue?
    The issue does not happen with Internet Explorer which leads me to believe this is an issue with Firefox. I downgraded to 3.5 and the issue still persists.
    Screen Caps: http://yfrog.com/1x46496103j and http://yfrog.com/n112309689j
    Any help?
    == URL of affected sites ==
    http://

    Try disabling hardware acceleration in your [http://www.macromedia.com/support/documentation/en/flashplayer/help/help01.html Flash settings] (using Firefox, right-click on any Flash object on a webpage, select Settings, uncheck "Enable hardware acceleration on the Display tab).
    Ref:
    http://kb.mozillazine.org/Flash#Performance_or_display_issues_with_certain_Flash_videos

  • CS5 - Why are Edit Auto Blend Layers (and Auto Align Layers) gray and not accessible?

    I have CS5 and would like to try focus stacking.  I File > Automate > Photomerge with a few photos.  They have been aligned in layers.  I would like to Auto Blend Layers but the function is gray and not accessible.
    Thanks,
    Mark

    Thank you THANK YOU.  As I was doing this I realized you asked me to show my selected layers.  I haven't been doing that.  I thought photoshop would blend all open layers.  Thanks again.

  • I set in prefferances plug-ins. Show all filter gallery groups and names, but they are still light gray and not selectable

    I set in preferences plug-ins. Show all filter gallery groups and names, but they are still light gray and not selectable

    They are being shown.  When Photoshop gray out items it means in the documents current state  that item is not supported,  Get the document into a state that the grayed out filters can be used.  Some filters mat not support some modes like CMYK. 32bit color, Lab etc. They seem to be listed but nor currently applicable. Note whem no document is open all are grayed out the when a simple clipboard image is open all are available.

  • I am trying to softproof an image using a CMYK .icc file. I sent an image from LR 5 to PS CC 2014, opened the Camera Raw FIlter, but the hyperlink to access workflow is not showing up in the CR dialogue box... Any ideas why this might be?

    I am trying to softproof an image using a CMYK .icc file. I sent an image from LR 5 to PS CC 2014, opened the Camera Raw FIlter, but the hyperlink to access workflow is not showing up in the CR dialogue box... Any ideas why this might be?

    I am trying to softproof an image using a CMYK .icc file. I sent an image from LR 5 to PS CC 2014, opened the Camera Raw FIlter, but the hyperlink to access workflow is not showing up in the CR dialogue box... Any ideas why this might be?

  • I try to insert some images on a website but the images are not in the right color mode. I do not know what to do? and also I have 1200 images to insert so I can not change one after one. So I need to set up an action, but I donot know how to do it... Tha

    I try to insert some images on a website but the images are not in the right color mode. I do not know what to do? and also I have 1200 images to insert so I can not change one after one. So I need to set up an action, but I donot know how to do it... Thanks

    What is the problem specifiaclly?
    If the images are intended for web use I would recommend converting them to sRGB which could be done with Edit > Convert to Profile or with File > Save for Web, but as including a Save step in Actions and applying them as Batch can sometimes cause problems I would go with regular converting.
    You could also try Image Processor Pro.
    Scripts Page

  • I am trying to make a signature in MS Word (2007) which includes a jpg image, but when I save it as a HTML file and attach it the text appers OK but the image doesn't. I have tried various formats but still no luck. Can anyone help?

    I am trying to make a signature in MS Word (2007) which includes a jpg image, but when I save it as a HTML file and attach it the text appers OK but the image doesn't. I have tried various formats but still no luck. Can anyone help? edit

    C'mon! Anyone???? I'm desperate!

  • Hey! I don't know if my MacBook Air is frozen, but the screen is gray with the apple logo and an icon below turning round and round as if it's opening, but has been like that for a few days. I've switched it off and then on again several times, still the

    Hey
    I don't know if my mac book air is frozen, but the screen is gray with the apple logo in the middle of the gray screen, with the 'booting' icon turning round and round. I have switched it off fron both the power and power button on the computer, it goes off, when I put it on, same screen comes on again. Help Please!

    Take each of these steps that you haven't already tried. Stop when the problem is resolved.
    Step 1
    The first step in dealing with a boot failure is to secure your data. If you want to preserve the contents of the startup drive, and you don't already have at least one current backup, you must try to back up now, before you do anything else. It may or may not be possible. If you don't care about the data that has changed since your last backup, you can skip this step.   
    There are several ways to back up a Mac that is unable to boot. You need an external hard drive to hold the backup data.
         a. Boot into the Recovery partition, or from a local Time Machine backup volume (option key at startup.) When the OS X Utilities screen appears, launch Disk Utility and follow the instructions in this support article, under “Instructions for backing up to an external hard disk via Disk Utility.”
    b. If you have access to a working Mac, and both it and the non-working Mac have FireWire or Thunderbolt ports, boot the non-working Mac in target disk mode. Use the working Mac to copy the data to another drive. This technique won't work with USB, Ethernet, Wi-Fi, or Bluetooth.
    c. If the internal drive of the non-working Mac is user-replaceable, remove it and mount it in an external enclosure or drive dock. Use another Mac to copy the data.
    Step 2
    Sometimes a boot failure can be resolved by resetting the NVRAM.
    Step 3
    If you use a wireless keyboard, trackpad, or mouse, replace or recharge the batteries. The battery level shown in the Bluetooth menu item may not be accurate.
    Step 4
    If there's a built-in optical drive, a disc may be stuck in it. Follow these instructions to eject it.
    Step 5
    Press and hold the power button until the power shuts off. Disconnect all wired peripherals except those needed to boot, and remove all aftermarket expansion cards. Use a different keyboard and/or mouse, if those devices are wired. If you can boot now, one of the devices you disconnected, or a combination of them, is causing the problem. Finding out which one is a process of elimination.
    If you've booted from an external storage device, make sure that your internal boot volume is selected in the Startup Disk pane of System Preferences.
    Step 6
    Boot in safe mode. Note: If FileVault is enabled, or if a firmware password is set, or if the boot volume is a software RAID, you can’t do this. Post for further instructions.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    When you boot in safe mode, it's normal to see a dark gray progress bar on a light gray background. If the progress bar gets stuck for more than a few minutes, or if the system shuts down automatically while the progress bar is displayed, your boot volume is corrupt and the drive is probably malfunctioning. In that case, go to Step 6.
    If you can boot and log in now, empty the Trash, and then open the Finder Info window on your boot volume ("Macintosh HD," unless you gave it a different name.) Check that you have at least 9 GB of available space, as shown in the window. If you don't, copy as many files as necessary to another volume (not another folder on the same volume) and delete the originals. Deletion isn't complete until you empty the Trash again. Do this until the available space is more than 9 GB. Then reboot as usual (i.e., not in safe mode.)
    If the boot process hangs again, the problem is likely caused by a third-party system modification that you installed. Post for further instructions.
    Step 7
    Launch Disk Utility in Recovery mode (see Step 1.) Select your startup volume, then run Repair Disk. If any problems are found, repeat until clear. If Disk Utility reports that the volume can't be repaired, the drive has malfunctioned and should be replaced. You might choose to tolerate one such malfunction in the life of the drive. In that case, erase the volume and restore from a backup. If the same thing ever happens again, replace the drive immediately.
    This is one of the rare situations in which you should also run Repair Permissions, ignoring the false warnings it may produce. Look for the line "Permissions repair complete" at the end of the output. Then reboot as usual.
    Step 8
    Reinstall the OS. If your Mac was upgraded from an older version of OS X, you’ll need the Apple ID and password you used to upgrade.
    Step 9
    Repeat Step 6, but this time erase the boot volume in Disk Utility before installing. The system should automatically reboot into the Setup Assistant. Follow the prompts to transfer your data from a Time Machine or other backup.
    Step 10
    This step applies only to older Macs (not current models) that have a logic-board ("PRAM") battery. Both desktop and portable Macs used to have such a battery. The logic-board battery, if there is one, is separate from the main battery of a portable. A dead logic-board battery can cause a boot failure. Typically the failure will be preceded by loss of the settings for the startup disk and system clock. See the user manual for replacement instructions. You may have to take the machine to a service provider to have the battery replaced.
    Step 11
    If you get this far, you're probably dealing with a hardware fault. Make a "Genius" appointment at an Apple Store, or go to another authorized service provider.

  • I am using Aperture 3 and I have just exported the edited picture to my desktop but the image which is now on my desktop appears to be unedited. Does anyone know why??

    I am using Aperture 3 and I have just exported the edited picture to my desktop but the image which is now on my desktop appears to be unedited. Does anyone know why??

    Did you export the master or version? Master will be unedited...
    File > Export > Version

  • I had backed up my iPhoto library from my old mac onto an external drive. When I got my mac book pro this year I could not open the files. The program recognises the folders and opens the rolls but the image is greyed out.

    My old power book used an older version of iphoto, when I bought my macbook pro recently I tried to upload, from an external drive, my backed up files. The program opens with all the relevant folders down the left side but none of the image files will open; the boxes that would contain them are there, but greyed out.

    I am now using iphoto '11 version 9.4.2, the original images that Im trying to recover from the ext HD are iphoto version 6. The EXT HD is formatted for mac and has been ok for all my other files that have been backed up.
    When I boot up iphoto version 11 it looks like it always does and will open my current library of images. If I try to get images from the ext hd in this program the folder info is ok (down the left side) but the image boxes are greyed out.

  • After upgrading, I can see the icloud choice in settings but it is pale gray and I am unable to select it.

    After upgrading, I can see the icloud choice in settings but it is pale gray and I am unable to select it.

    I have the same problem. In your mail settings are the "Accounts" options also faded? My twitter option is also faded as well and I have no idea whats going on (iPhone 4). I seemed to have set up iCloud through some of my apps but I can't manage them at all in settings. My mail is also working fine but I can't log off of any of them.

  • TS3899 When i send an image via gmail on my iphone 5s, the message gets sent, but when received, the image is invalid and the mail message says that it has noncontent. I've tried turning off the phone completely, deleting all mail accounts and then reinst

    But when received, the image is invalid, and the mail states that the message has no content. Help, please!

    Hello Bunk94,
    It sounds like iMessage may be activated with the wrong phone number. Let’s see if we can resolve this. First, go ahead and sign out of iMessage and FaceTime:
    If you can't send or receive messages on your iPhone, iPad, or iPod touch - Apple Support
    http://support.apple.com/en-us/HT204065
    Sign out and back in to iMessage and FaceTime
    Go to Settings > Messages > Send & Receive, tap your Apple ID, then tap Sign Out.
    Go to Settings > FaceTime, tap your Apple ID, then tap Sign Out.
    Afterwards, turn iMessage and FaceTime off and restart your device:
    If you get an error when trying to activate iMessage or FaceTime - Apple Support
    http://support.apple.com/en-us/HT201422
    Turn off iMessage and FaceTime and restart
    Go to Settings > Messages and turn off iMessage.
    Go to Settings > FaceTime and turn off FaceTime.
    Restart your device.
    Turn iMessage and FaceTime back on.
    Thanks,
    Matt M.

  • My Mac will burn a DVD from iPhoto but the images and videos will not play on my DVD player. I am using DVD-R disks

    My Mac will burn a DVD from iPhoto but the images and videos will not play on my DVD player. I am using DVD-R disks

    Hi john, try Burn...
    http://burn-osx.sourceforge.net/Pages/English/home.html

  • Firefox upon opening an image in a new tab, centers the image from top and bottom and surrounds the image with a grey frame. Just started having the problem today, searched Google to no avail.

    Firefox upon opening an image in a new tab, centers the image from top and bottom and surrounds the image with a grey frame. Just started having the problem today, searched Google to no avail.

    Oh wow, looks like a new feature.
    The "page" links in a stylesheet with the address "resource://gre/res/TopLevelImageDocument.css". If you remove that reference, then the image displays in the old style.
    '''''Edit: Please skip the rest of this post and check out the next one.'''''
    There might be a more elegant solution than that, but you could use a bookmarklet to strip out that link when you want to view the page in its old style. A bookmarklet is a snippet of JavaScript you save on the Bookmarks toolbar for quick access.
    First, copy the following code to the clipboard (it's all one long line):
    <br>javascript:var ssheet=document.querySelector('link[href="resource://gre/res/TopLevelImageDocument.css"]'); if(ssheet)ssheet.parentNode.removeChild(ssheet); void 0;
    Next, if you are not displaying the Bookmarks Toolbar, use View > Toolbars > Bookmarks Toolbar to display it. (If you aren't using the classic Menu bar, press Alt+v to call up the old View menu. Right-clicking the gray area just below the page address also allows you to display the Bookmarks Toolbar.)
    Right-click on the Bookmarks Toolbar (or Mac equivalent of right-click!) and choose New Bookmark.
    Paste the code into the Location box (the second box).
    Then type a useful name in the Name box (e.g., Oldstyle Picture) and click Add.
    Now, when you want to tweak the image display, click the button to run the script.
    Manual clicking is a hassle, so it might make sense to look into other solutions. (Greasemonkey didn't seem to work; I think it might not run on .jpg files.)

  • When I type in my password into the login screen I get the rainbow pinwheel and then the screen turns gray and goes back to account selection... How do I access my account?

    Today I was doing my chemistry homework when all of a sudden my mid 2011 MacBook pro running Lion 10.7.4 started going very very VERY slowly to a point where it was unusable. I restarted my computer and went to type in my password. When I did this, the computer recognized the password and began to boot yet the pinwheel came on and the screen turned gray and went back to the account selection screen. It continues to do this everytime I enter my password and I can no longer access my account. How do I fix this.

    You can take some of the steps here, #4, #5 or even trying a #18
    Step by Step to fix your Mac
    but I suspect your going to first have to create a data recovery drive
    Create a data recovery, undelete boot drive
    to get your data off the machine,
    then do a #20 to eliminate the bad sectors as that's why your getting the "pinwheel" it's getting a delay reading from the drive, right when your trying to log in too, what a bad spot for it to happen.
    Step by Step to fix your Mac

Maybe you are looking for