Blur an image - it just draws a black box!!

Hi,
I'm trying to write a method to blur an image and draw it on a panel. It just draws a black box (at least its the right width and height though!)
I'm not too familar with Graphics 2D so I've no idea what the problem is - I've looked at several examples and as far as I can see my code is the same..
This is the main class:
public void blur()
      currentImage = images[lsClips.getSelectedIndex()];
      int height=currentImage.getHeight(this);   //make new buffered image same width, height as original image
      int width=currentImage.getWidth(this);
      System.out.println("the width is"+width);
                                                   //convert original image to a buffered image
      BufferedImage srcBuffImg= new BufferedImage(width,height, BufferedImage.TYPE_INT_RGB);
      Graphics2D big = srcBuffImg.createGraphics();
      big.drawImage(srcBuffImg,0,0,processedImagePanel);
      processedImagePanel.setImage(srcBuffImg);
      processedImagePanel.repaint();
      processedImagePanel.revalidate();
}processedImagePanel is a customised JPanel class that I created to display the image on. I think that the setImage() method works propperly - the buffered image is not null when I checked it in this method. This is the setImage() and paintComponent() methods of that class.
public class ImagePanel extends JPanel
private BufferedImage buffImg;
float[] elements = { .1111f,.1111f, .1111f,
                      .1111f,.1111f, .1111f,
                      .1111f,.1111f, .1111f,};
  public void setImage(BufferedImage img)
    processing = true;
    this.buffImg = img;
    this.repaint();
    this.revalidate(); 
  protected void paintComponent(Graphics g)
    super.paintComponent(g); //paint background
    if(buffImg!=null )   //draws blurrred image
      System.out.println("DRAW Buffered img");
      Graphics2D g2 = (Graphics2D) g;
      int w = getSize().width;
      int h = getSize().height;
      int bw = buffImg.getWidth(this);
      int bh = buffImg.getHeight(this);
                    //create a buffered image for the processed image
     BufferedImage destBuffImg = new BufferedImage(bw,bh,BufferedImage.TYPE_INT_RGB);
     Kernel kernel = new Kernel(3,3,elements);
     ConvolveOp cop = new ConvolveOp(kernel,ConvolveOp.EDGE_NO_OP,null);
     cop.filter(buffImg,destBuffImg);
     g2.drawImage(buffImg,cop, 10,10);
}I would be very grateful if anyone could give me any suggestions..

BufferedImage srcBuffImg = new BufferedImage(width,height, BufferedImage.TYPE_INT_RGB);
Graphics2D big = srcBuffImg.createGraphics();
big.drawImage(srcBuffImg,0,0,processedImagePanel);
processedImagePanel.setImage(srcBuffImg);
processedImagePanel.repaint();
processedImagePanel.revalidate();I think the bug is here: why do you paint the (empty) buffered image in itself? I guess, you wanted to paint the currentImage to the bufferedImage.

Similar Messages

  • Exporting to Quicktime and just get a black box with audio

    I'm trying to export a finsihed movie to QT. But after it compresses and no matter what settings i try, i just get a black box in the QT player with audio only. I have QT 7.2 -- anyone have a clue?

    I imported a 175MB .mov into the project. I added a few minor audio elements and a few basic transitions. I exported using H.264 with default settings (and I've tried other codecs as well). After the export, I click on the .mov file and when it plays, the screen is black and all I get is audio.

  • Creative Cloud installed but just a blank black box - can't access anything?

    I have just started with CC - downloaded Desktop App but when I open it, it is just a black box with nothing in it?

    Black Screen at Sign-in | Creative Cloud Desktop app
    https://helpx.adobe.com/creative-cloud/kb/black-screen-sign-in-creative-cloud.html

  • I am running a website called mediahawk, I cannot play audio files I just get a black box where the media player controls are

    I log onto the site when I try to play an audio file I see a black rectangel where the media played controls should be and the file will not play.
    I have tried updating the plugin.
    It works fine in IE.
    Anyone have any ideas

    -> Update Firefox to the latest version 10.0.1
    * [[Installing Firefox on Windows]]
    * [https://support.mozilla.com/en-US/kb/Template:clearCookiesCache/ Clear Cookies & Cache]
    -> ALL your Firefox Plugins (Adobe Flash, Java, Silverlight) are extremely out-dated
    * Update All your Firefox Plugins -> https://www.mozilla.org/en-US/plugincheck/
    * '''When Downloading Plugins Update setup files, Remove Checkmark from Downloading other Optional Softwares with your Plugins (e.g. Toolbars, McAfee, Google Chrome, etc.)'''
    Check and tell if its working.

  • PhotoBooth - iMovie Black Boxes

    I have seen only a few people mention this problem online, and noone seems to get an answer, though at least one person said that completely reformatting seemed to fix the problem, but this isn't an option for me...
    I updated my MacBook Pro (17" Mid-2007) and my Mac Pro (8-Core) both to 10.7, and subsequently to 10.7.2
    After update, when I open PhotoBooth on my MBP, the effects "Lovestruck" and "Dizzy" have little black boxes (the alpha channel?) showing around the hearts and birds, likewise any 3rd party effects that mask out sections using an alpha (like the popular package that includes a 'mask' allowing your eyes and mouth in the faces of a gorilla, a clown, and Steve Ballmer (a clownish gorilla) only have black spaces where you should be seeing parts of my face. Also, when I use the 4-up photo effect, the image I see, when Photo Booth doesn't crash, is that of two black boxes, one askew above the other. The thumbnail of the image is correct, though.
    I have searched all over, but the only other problem people seem to have with Photo Booth involves it opening in 32-bit mode and no effects showing up. This is not the issue I am having, and the problem is not isolated to PhotoBooth, as iChat also exhibits the same problem when I try to use the effects.
    I chose to post this question in the iMovie section to hopefully avoid people telling me to 'uncheck 32-bit', and also because the problem affects certain iMovie themes. The Photo Book theme, for instance, refuses to place a photo or video in the opening of the book. It just stays a black box. Also, if I change any text in any of the other themes, then the text is replaced with plain black boxes, or an extremely generic font.
    I don't believe this to be an isolated hardware issue, though it may be a conflict with other software. My MBP did this from day 1 of the 10.7 update, but I assumed it was due to the age of my machine, older/slower graphics and RAM, etc. But I recently got a used 8-core Mac Pro, with the 512MB X1900 graphics card and 14GB of RAM. When it arrived, the first thing I did was install 10.7 and the 10.7.2 update. No problems. Installed Final Cut Studio 3 apps, and also Adobe CS5 Master, and iLife 11. At some point during those installs, I opened Photo Booth and showed my wife the Lovestruck and Dizzy effects, which were working fine, later when I went to show the effects to my children, it looked just like my MBP. I opened iMovie, and it also has the same problem. I do not know which apps I installed after showing the effects to my wife, but I do know that the ONLY additional apps that have been installed on this machine are the ones I mentioned. I installed 10.7.2, FCS3, CS5, iLife '11 - oh, and iStat Menus. That's it. I don't know which of these, if any, could be causing the problem, since my MBP does not have iStat Menus installed, and is running Final Cut Studio 2, and Adobe CS4 - both older versions than I use on the Mac Pro.
    My iMac shipped with 10.7 and iLife, and has been updated, but I have been reluctant to install my Adobe or Final Cut packages on it for my wife to use, as it is currently the only machine I have that is still able to use iMovie's themes properly for home videos.

    I did close and restart firefox when trying to HWA fix yeah, also I have no addons.

  • Flash player 11 on windows 7 64b and ie9 64b - videos on facebook show black box and won't play

    flash player 11 on windows 7 64b and ie9 64b - videos on facebook show black box and won't play
    tried updated graphics device driver, did not fix
    tried all the steps to clear cache, did not fix
    disable hardware acceleration, did not fix
    some videos in facebook play, youtube plays, but some videos just play a black box
    thanks for any help!

    If you right click the black box, does the browser menu appear or Flash Players?

  • In the C309, How can I use just the regular black ink cartridge only?

    Hi
    I just bought a HP C-309 a short time ago.  I bought a HP reg black cartridge XL quite quickly.  This thing is a sweet
    machine, works perfectly, but is a terrible terrible ink hog. 
    Had I known, I would have gone for the Kodak which touts much lower ink costs.
    I only use this thing for documents.  I do not want to keep putting color cartridges in.  They are all on low except for the black XL cartridge.  How can I set it up to use only this cartridge for black and white..and just leave the color ones on empty.
    I will have to get rid of it if I have to keep feeding it this way.  The ink levels seem always low.  By the way, the help asks me for model number.  They want to know whether it is 309n or 309g.  I see no way to find out..no notations on machine or purchase documents.  HP, if  you need this info...make it easy for the consumer to FIND the info...gheesh!

    Hi   lyn1360
    There are several circumstances when color ink may be used—primarily to improve print quality, and sometimes to improve printer reliability—even if the document appears to be only black text-and-graphics. Many HP printers utilize chemical interactions to improve the quality and permanence of plain paper black text-and-graphics by adding small amounts of color ink to certain black areas. Some dark images which look black to human eye may contain a combination of black and color inks. For black and white images and photos or grey black which we think as black, a blend of colors called "composite black" may be used to achieve significantly better image quality and smoother gray tones than can be accomplished with black inks alone. Some inkjet printers utilize pigmented black ink, which is incompatible with some inkjet photo paper. In this case, dark or black areas are made up of color inks.
    For users who wish to print utilizing just black ink (despite the reduced print quality), many HP printers offer options. For example, a driver color setting (by selecting "print in grayscale with the black cartridge only" in printing preferences) specifies printing using only black ink. In addition, many IPH printers can operate in "reserve mode," which allows the user to continue to print with just the black cartridge when the color cartridge is removed or not installed.In HP IIC systems like your printer C309, all supplies are required to be installed in the printer for the printer to function.
    To find the correct model number for your printer, you can just open the carriage access door and on the right side you can see the model number. For OJ Pro printers, we need to open the cartridge access door on the front left side to see the model number.
    For more info regarding the ink usage, check the below link:
    http://h10060.www1.hp.com/pageyield/en-019/article​s/howInkIsUsed.html?cCode=us
    Mark this post as answered so that others might find it useful
    Say "Thanks" by clicking the Kudos Star in the post that helped you.
    Please mark the post that solves your problem as "Accepted Solution"

  • Why a black box (or fuzzy "i") when opening an image?

    In one particular folder in "Events", when I click on an image to open, it opens to a black box or at best a fuzzy "i" - were the image should be, what has happened? All other options appear as normal but if I click "edit"for example - my options become unavailable and still have the black box were the image should be. 
    All other folders in Events are fine and no such problem occurs. In checking "preferences" nothing has changed as the problem folder preferences are the same as the others - likewise not aware I've changed anything either. I've gone into 'help" but just cannot find anything there unless I'm looking into the wrong place?
    Currently I'm on OS "X" 10.6.8 using iPhoto 09  - 8.1.2 (424) which hopefully will assist too?

    In your first post:
    In one particular folder in "Events", when I click on an image to open, it opens to a black box or at best a fuzzy "i"
    In your most recent post
    Currently no ! appears now, just a black box.
    These are different issues with potentially different resolutions. Assuming that there is no exclamation mark warning, but just a black screen:
    There are several possible causes for the Black Screen issue
    1. Permissions in the Library: Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Include the option to check and repair permissions.
    2. Minor Database corruption: Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild.
    3. A Damaged Photo: Select one of the affected photos in the iPhoto Window and right click on it. From the resulting menu select 'Show File (or 'Show Original File' if that's available). Will the file open in Preview? If not then the file is damaged. Time to restore from your back up.
    4. A corrupted iPhoto Cache: Trash the com.apple.iPhoto folder from HD/Users/Your Name/Library/ Caches...
    5. A corrupted preference file: Trash the com.apple.iPhoto.plist file from the HD/Users/ Your Name / library / preferences folder. (Remember you'll need to reset your User options afterwards. These include minor settings like the window colour and so on. Note: If you've moved your library you'll need to point iPhoto at it again.)
    If none of these help:
    As a Test:
    Hold down the option (or alt) key key and launch iPhoto. From the resulting menu select 'Create Library'
    Import a few pics into this new, blank library. Is the Problem repeated there?
    but this is just one folder with 211 images - all other folders are fine and working as expected. Reading what you have written, you are referring to the whole library which seems to be extreme?
    This is not just one folder or just 211 images. What you are seeing are symptoms of an issue in the Database file. If this file is damaged then your Library is damaged and this is what needs to be fixed. That's why deleting and re-importing won't help. You'll be re-importing to a database that is known to be damaged and unstable.

  • Image no longer displays, appears black

    I'm running CC on iMac with Mavericks. I'm editting images building up adjustment layers and I get to 5 or 6 layers and the the image no longer appears - the edit window just shows a black rectangle, the same size as the image. The image is still in memory - if I export, save i can view the image. Adjustments still work - I've tested changing canvas size. I can run pluggins like Nik and the image appears in Nik but all black when it's returned to Photoshop. My only work around is to save image, quit and restart PS. This is seriously slowing down my work flow. This never happened when I was using CS6. I'm working on a high spec imac so shouldn't be a performace / resource issue. I'm only running PS and Lightroom.
    Processor  3.4 GHz Intel Core i7
    Memory  24 GB 1333 MHz DDR3
    Graphics  AMD Radeon HD 6970M 2048 MB
    Software  OS X 10.9.1 (13B42)
    Adobe Photoshop Version: 14.1.2 (14.1.2 20130923.r.427 2013/09/23:23:00:00) x64
    Free memory: 12119 MB
    Memory available to Photoshop: 22586 MB
    Anyone else experienced this problem? Is there a fix, work around?
    Thanks.

    Google updated the plugins recently to correct this problem:
    https://support.google.com/nikcollection/answer/4400822?hl=en&ref_topic=3001406
    Version 1.109 (December 11/2013) is the latest:
    Fixed black or white tile artifacts that might have occurred after returning to Photoshop from plug-ins
    You can find out the version you have installed by launching Photoshop:
    On Mac: Select Photoshop>About Plug-in>Analog Efex Pro… (or any other NIK Plug-in)
    On Windows: Select Help>About Plug-in>Analog Efex Pro… (or any other NIK Plug-in)

  • Problem with .png images being black boxes in InDesign

    Hello,
    I'm hoping someone might be able to help me with a problem I'm having with some .png files.  When I try to place certain .png files in my InDesign document, they come in as just black boxes.  The .png files are created by a third party application, (EditLive w/MathFlow)  But if I view the .png files in Fireworks or other image viewers, they appear to be fine.  I have tried looking at the image properties inside InDesign, to see if by tweaking them it might work, but I am not a graphic designer by trade so my knowledge is rather limited.  Any help would be greatly appreciated.
    Specs:
    Windows XP
    CS4 Suite including:
         Adobe InDesign CS4
         Fireworks CS4
    Thanks,
    Josh

    That worked!  Mostly.  The little preview box on the file upload dialog still shows a black box.  But when the image is placed inside the doc it looks perfect.  Well, as perfect as the .png can look.
    Is there any way within InDesign to "ignore" the alpha channel or whatever of the graphic?  I have access to the IDML as well as the normal application interface & the SDK through the InDesign Server.  I'd prefer not to be reliant on opening the image in another tool, as we have a large number of images to process some times & it could get annoying.  If not, I can try contacting the 3rd party group that is generating the .png & see if they can better handle the alpha channel when they're creating the image maybe...
    And thanks for the quick responses!
    -Josh

  • Photoshop has suddenly started placing a large black box ontop of the image - its only present on the monitor if I save the image it has gone - the box (some times black sometime white) obscures what Im doing

    This has suddenly started - a black box (some times white )
    appears over the top of the image & obscures what Im doing. Its not present when I save the file - only when Im trying to work on it. I cant see what Im doing to the image
    Help !!
    James

    Looks like a bug somewhere in PS - would be interesting to find out if it's happening to more than just us.
    Actually this looks a lot like a bug with a GPU driver.
    Has the issue reoccurred since you turned off GPU usage?
    My trouble is I just use PS and expect it to work.
    Well, as Adobe did not make your computer, OS, GPU, … you have to do your own trouble-shooting to verify if the issue is actually with an Adobe application or with another component.

  • Loss of the transparent color in images inserted into Draw

    I need to float an oval portrait image over a background image, so to get to the oval I made the portrait image corner sections transparent using Graphic Converter and saving as a PNG, which supports the transparent color. Problem is that after the PNG image is inserted into the Draw document containing the background image, the transparent sections are black and not transparent. Anyone else know about this problem?

    Welcome to Apple Discussions Jim
    I've not had much success, & none recently, getting images to be transparent in AppleWorks. However, a few years ago I accidentally discovered that if the image is flipped or rotated the background will become transparent. Since you are using Graphic Converter, you can do what I did. Before saving the image in Graphic Converter flip it horizontally so that once imported into your AppleWorks document you can "re-flip" it & the background will be transparent. Another option is to rotate the object 1 degree in AppleWorks.
    I now use Pages for my desktop publishing & it has no problem with transparent PNG or GIF images.
    Peggy

  • How to blur an image?

    Could someone please provide an example of the easiest way to blur an image. I have googled for it but I haven´t find any examples that made me more clear over how it works.
    What classes do I need, except the Image class?
    Thanks in advance!
    EDIT: I have found this method:
    public void blur() {
        float data[] = { 0.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f,
            0.0f, 0.0f, 0.0f };
        Kernel kernel = new Kernel(3, 3, data);
        ConvolveOp convolve = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP,
            null);
        convolve.filter(biSrc, biDest);
        bi = biDest;
      }I have tested changing the data[] array values and the image is getting blurred. But what kind of values are these 9 elements?

    If you change the data[] array to something like this
    float[] data = {1/9f,1/9f,1/9f,
                    1/9f,1/9f,1/9f,
                    1/9f,1/9f,1/9f}; then you would have stumbled upon one of the easiest ways to blur an image. A convolution just basically takes the above array and "places" it on the image. In the above case I have a 3x3 "window" that is moved across the image. At every point the pixels are multiplied with the corresponding value in the window and then added together. The sum becomes the new value for the center pixel.
    So in the above case, I'm taking 1/9 of every pixel, summing them, and making the sum the center pixel. For a colored image this is done on all three channels (red, green, blue). The resulting image then has the property that every pixel has a little bit of its neighbors' colors. This achieves a blurring effect. Of course, there are more accurate (and still fast) ways to go about blurring, but a box-convolution where each array element is +1/size+ is probably the easiest.
    Now as far as convolutions go, you can manipulate the values in the window or the dimensions of window to achieve various effects (median filter, primitive edge detection, sharpening, embossing, ect..). In fact, convolutions are so important to image processing that most computers have built in hardware to speed up the calculations. The ConvolveOp in core java tries to utilize this acceleration, but has certain annoying limitations.
    [Here's a good source on blurring|http://www.jhlabs.com/ip/blurring.html]

  • I just Draw a shape in Geometry and key framing and everything is good ,bu

    I just Draw a shape in Geometry and key framing and everything is good ,but as soon as I get to the secondary for set the changes everything will change !The shape will automatically change its place to couple pixel up and to the right ! my footage is in 2K red and was shot by Red Camera . I really don`t know what is the problem , any helps ?

    Howdy,
    This is a really good question about one of the bigger challenges of building a 3D project. When you add objects to the Canvas (including drawing), they get added in the camera's viewspace, facing the camera and sharing the same up-vector (i.e. positive Y is up). This is all well and good, but what about doing what you ask, where you want to add an object in the localspace of another object? Let's look at your example: adding a shape that is coplanar to a photo, with the camera not necessarily aligned with the photo.
    As Mark suggested, you can draw the shape in the camera's viewspace and then drag-and-drop the Position and Rotation channels from the photo onto the shape. This will replace the shape's Position and Rotation values with that of the photo, making them coplanar and located in the same place. The shortcoming of this method is that you draw the shape at a size that seems correct in the Canvas, but once it's moved to the same place as the photo, it will often turn out to be too small or large. Then you have to make further tweaks.
    Another solution is to use the Isolate command. Isolate temporarily aligns the current view to the selected object and solos that object. So you could isolate the photo and then draw the shape in the Canvas and it will be coplanar with the photo. The only caveat is that the moment you finish drawing the shape, it will disappear. This is because the photo is still isolated (and soloed). As soon as you de-isolate the photo, everything will reappear.
    The easiest way to use Isolate for new photos—not ones already in the project—is to place the photo in a 3D group, position the group where you want the photo and shape to be, then isolate the group and add anything you want to it (shapes, image, text, etc).

  • When i paste my own albumart to a song, the picture just turn up black in the iTunes

    As i wrote the pasted albumart picture just turn up black in the iTunes player.
    Before everything work great and the pictures appeard as they should but now they are just black
    Any ideas?
    Thanks in advance

    mykologen wrote:
    As i wrote the pasted albumart picture just turn up black in the iTunes player.
    Before everything work great and the pictures appeard as they should but now they are just black
    Any ideas?
    Thanks in advance
    It is a new bug.  I'm consistently seeing it in 10.4.
    Paste does not work correctly, but dragging the image into the space on the Artwork tab will work.  Also, if you save the picture file, you can use the Add button and navigate to the saved location.  I know that neither of these is as convenient, but they do work.

Maybe you are looking for