Median Filtering using JAI

Hi, I am not so familiar with JAI API but I do use some of it sometimes in my coding. I am trying to figure out why I keep receiving the same error message when applying MedianFiltering to my image as in the following code snippet:
public BufferedImage medianFilter (Image image){
ParameterBlock pb = new ParameterBlock();
pb.add(image);
PlanarImage input = (PlanarImage)JAI.create("awtImage",pb);
pb.addSource(input);
pb.add(MedianFilterDescriptor.MEDIAN_MASK_SQUARE);
pb.add(3);
input = JAI.create("medianfilter", pb, null);
BufferedImage nImage = input.getAsBufferedImage();
BufferedImage filteredImage = new BufferedImage(nImage.getWidth(null), nImage.getHeight(null), BufferedImage.TYPE_INT_RGB);
Graphics g = filteredImage.getGraphics();
g.drawImage(nImage, 0, 0, null);
return filteredImage;
ERROR MESSAGE
java.lang.IllegalArgumentException: MedianFilter - Parameter value`s class (sun.awt.windows.WImage) is not an instance of the parameter class (javax.media.jai.operator.MedianFilterShape) for parameter "maskShape".
at javax.media.jai.JAI.createNS(JAI.java:1091)
at javax.media.jai.JAI.create(JAI.java:977)
at imagesegmentationrgb.ImageSegmentationRGB.medianFilter(ImageSegmentationRGB.java:210)
I have tried to amend it for so long and I don't know what else to do. Could anyone help me? Cheers and thanks.

My solution would be to work with the image in its raw format. Extract the image into a 2 dimensional array, loop throught the rows and columns and compare to your zero crossing window detector. after you have aquired the new image array, you set pixels that are next to an edge 0 and the rest #ffff. this will create a binary image (black and white) with the edges black and rest white. Be careful of your conventions used to determine what are edges. This may seem primitive, but thats just the way i think :P
-fastrike

Similar Messages

  • Problem while loading a JApplet ( which uses JAI ) on Netscape across ssl

    Hi Folks...
    I m having some problem in applet.. can any1 of u guys help me???? My problem is as follows..
    I m having 2 JApplets (Swing applet) one of the applet is using JAI (Java Advance Imaging APIs). I m trying 2 load both the applets in IE as well as in Netscape across SSL (ie thru https protocol) .Both the applet can be loaded on IE across SSL. but when i m trying to load the applet on Netscape, one of the applet which is using JAI is not getting loaded across SSL. The other applet which is not using JAI is running fine across SSL on Netscape also.
    I m getting some exception.. Is this exception comming bcoz JAI is not compatible with Netscape r bcoz of somethinf else??? If it is bcoz of the fact that Netscape does'nt have any support for JAI across SSL. then watz the possible solution 4 that. How can i overcome by this problem. Its very urgent.. i need to do it any how... Plz plz help me out if u guys have any idea abt this.. any help is most welcome..
    My ids r
    [email protected]
    [email protected]
    tks...
    Jameel

    Exactly what exception are you getting? That will really help in determining the problem. Also, do you have the same problems when going over a regular connection (i.e. not over SSL)?
    Kate

  • Problem Printing Images Using JAI

    I'm using JAI in an application that prints images. My program works fine on my development machine (Windows XP), but when I put it on my Windows Server 2008 r2-64 bit, it crashes for certain images (these are large images of land plats) that go to a particular printer (OCE PlotWave 300) It prints my smaller images that are printing on a variety of printers just fine (images of Mortgages etc..) and it prints everything just fine on my development machine. What could possibly be causing this?
    Edited by: LongStranjeTrip on Feb 2, 2011 4:34 PM
    Edited by: LongStranjeTrip on Feb 4, 2011 8:11 AM

    I'm using JAI in an application that prints images. My program works fine on my development machine (Windows XP), but when I put it on my Windows Server 2008 r2-64 bit, it crashes for certain images (these are large images of land plats) that go to a particular printer (OCE PlotWave 300) It prints my smaller images that are printing on a variety of printers just fine (images of Mortgages etc..) and it prints everything just fine on my development machine. What could possibly be causing this?
    Edited by: LongStranjeTrip on Feb 2, 2011 4:34 PM
    Edited by: LongStranjeTrip on Feb 4, 2011 8:11 AM

  • How to resize image in JSP using JAI ??!!

    Please help me how to resize an JPEG image from my JSP, could I use JAI lib ? how ?

    Hello,
    I had the same problem few months ago ( in that case i used Jimi instead of JAI).
    The answer to your question is: use the java class called "Image".
    Infact you can use JAI just for load or save to disk your image that you have to resize and then use the following code to resize the image :
    Image imgResized = img.getScaledInstance(100,1,Image.SCALE_AREA_AVERAGING);
    The object "img" is the image to resize and the object "imgResized" is the image resized with width equals to 100 and with a right height.
    I used Jimi just to save my image and i think that with JAI there is a method to do this.
    You can use JAI to load in memory your image too so you can avoid problem with MediaTraker class.
    I hope that this can help you.
    Cheers.
    Stefano

  • Conditional Filters using case statements

    Hello,
    I have a table view which displays Total Quota and Theatre Quota. Against the Total Quota, there are 2 values - Rollover Revenue and Theatre Revenue. Against the Theatre Quota, there is only Theatre Revenue.
    What I want to accomplish is to display only the Rollover Revenue Aggregated Quarterly number whenever there is a Total Quota number and not display the Theatre Revenue number
    In the table view,
    Year Name     Quarter Name     Quarter Name Sort     Person Region     Quota Name     Quarterly Quota     Credit Amount     QTD Attainment     Credit Type Name
    YEAR-2012     QTR-1-2012     QTR-1-2012     750     Total Quota     6,128,500     5,492,081     89.62%     Rollover Revenue Aggregated Quarterly
                   750          6,128,500     5,344,000     87.20%     Theatre Revenue
         QTR-2-2012     QTR-2-2012     750     Total Quota     5,922,500     5,890,264     99.46%     Rollover Revenue Aggregated Quarterly
                   750          5,922,500     6,120,000     103.33%     Theatre Revenue
         QTR-3-2012     QTR-3-2012     750     Total Quota     5,716,500     0     0.00%     
         QTR-4-2012     QTR-4-2012     750     Total Quota     5,510,500     0     0.00%     
    I used an example in the following link:
    http://oraclebizint.wordpress.com/2008/02/06/oracle-bi-ee-101332-conditional-filters-using-case-statements-in-filters/
    and applied the example in my scenario:
    CASE WHEN Quota."Quota Name" = 'Total Quota' THEN "Credit Type"."Credit Type Name" ELSE 'Dummy' END != 'Theatre Revenue'
    I still get duplicate rows.
    Thanks.

    Could you suggest any solutions for this problem where I can conditionally hide the number only for a certain type of data and not for all type of data?
    Thanks.

  • Downgrading Image Resolution Using JAI

    I am interested in downgrading the resolution of TIFF images that I am inserting into a PDF to reduce the document's file size. The TIFF images are either CCITT G4 bitonal or JPEG RGB. What would be the best approach to doing this using JAI?
    I appreciate any suggestions.
    Youssef Eldakar
    Bibliotheca Alexandrina

    Youssef
    The following code will load a TIFF image (or JPEG or some other formats that I can't remember) into a PlanarImage object and then rescale it according to the scale factors and then save as a TIFF.
    For example if you wanted to change a 320 x 240 image to a 160 x 120 use xScaleFactor and yScaleFactor of 0.5.
      public static PlanarImage rescale(String inputFilename, String outputFilename, float xScaleFactor, float yScaleFactor)
            // load the image from the file
            PlanarImage image = JAI.create("fileload", inputFilename);
            ParameterBlock rescaleParameters = new ParameterBlock();
            rescaleParameters.addSource(image);
            rescaleParameters.add(xScaleFactor);
            rescaleParameters.add(yScaleFactor);
            // saving as TIFF is a little more complicated than loading
            try
                FileOutputStream out = new FileOutputStream(outputFilename);
                TIFFEncodeParam parameters = new TIFFEncodeParam();
                ImageEncoder encoder = ImageCodec.createImageEncoder("TIFF", out, parameters);
                try
                    encoder.encode(image);
                    out.close();
                catch (IOException e)
                    System.out.println("Failed to encode the image");
            catch (java.io.FileNotFoundException ioEx)
                System.out.println("Could not write to file " + filename);

  • How can I achieve IOS content filtering using a Cisco router

    Good day Everybody.
    I would like to set up content filtering using IOS on my Cisco router. I already know how to do URL filtering but I want to restrict access to sites based on categories.
    Is this possible without having to introduce an external device?

    Natively in IOS this is not possible. However you can configure CWS (Cisco Web Security). The router will forward web requests to a cloud based web security service.
    http://www.cisco.com/en/US/prod/collateral/vpndevc/ps10142/ps11720/data_sheet_c78-729637.html

  • Show values of filters used in the columns

    hi experts
    Probably it is very simple but I don´t find how to do it. I would like to see in the query the values of the filters used to calculate the columns.
    I.e. One column is the amount of the net income for one month. The month is asked when I execute the query but when the query is executed I don´t see in the screen the month used.
    Thanks and regards

    Luis,
    I think you are wanting to use text variables on the columns to get the values of the month. To do this go into the column name and type &. It will prompt you to select, create, or edit a text variable. You can create a variable here to display the value of the characteristic your variable is on (i.e Month).
    Hope this helps,
    Rusty

  • IOS Content Filtering Using TrendMicro: Can I customize the block-page redirect-url?

    I have IOS content filtering using the Trend Micro subscription service working on a 2911 running 15.1.(3)T3 with the security license option and a 30 day demo Trend subscription.
    Once I figured out that the content filtering for Trend appears to be completely broken in 15.2 (even using docs for 15.2) I went back to 15.1 and it works great.
    Everything seems great so far except I would like to have a more 'fancy' or custom blocked page where a user can have a couple links to either go to the trend micro reporting page http://global.sitesafety.trendmicro.com/result.php or some other page, and maybe some branding so they know the page is coming from our network and is not some fake security thing or phishing attempt or whatever.
    I know I can use the 'parameter-map type urlfpolicy trend ' section to do a tiny bit of customization of the text that appears on the default blocked page display and there is an option for it to go to a simple redirect instead ('block-page redirect-url') but I wonder if anyone has any ideas on how to do more with either the built in page or the redirect-url to keep the information of what page the user was trying to access and why it was blocked (category etc.) while adding more features.
    Thanks!
    Oh, one last thing, this doesn't support any kind of 'user override' or anything like that does it? So that a network can have a filter applied but an admin could override the filtering to allow temporary access to something?

    Hmm... no thoughts over the weekend. Anyone?

  • OBIEE 10g answers display filters used in result

    Hi,
    Is it possible to display the values of filters used in the result of an answer report?
    E.g.
    answer report:
    branch, sales
    Filters: branch = 1
    I want to show the filters used in the result in compound view. I have tired different views, none of them seems to work for this.
    I know I can put it in a dashboard with prompts so users can see the filters applied. But just curious is there any way to do it in the answers? Because in dashboard, it only prints PDF or HTML, but in answers it can print excel, which is what I want.

    In compoud Layout itself, there is option to add filter view. in the top of the answers resuls, you can find some tools and tabs, there you can find add view, by adding the filter view you can have the filter in the compound layout and you can see it printed in PDF like below.
    Fiscal Period
    Closing Amount
    2012-12     
    11.9
    2013-01    
    93.52
    Fiscal Period is equal to 2012-12 , 2013-
    01
    Try it and let me know if it works.

  • Filling shapes using JAI

    hi,
    how can I fill a shape using JAI ? Is it a kind of convolution operation ?
    I have binarized my image, and now I have a group of black pixels (we say, an hole) inside a face of white pixels.
    thank you

    My solution would be to work with the image in its raw format. Extract the image into a 2 dimensional array, loop throught the rows and columns and compare to your zero crossing window detector. after you have aquired the new image array, you set pixels that are next to an edge 0 and the rest #ffff. this will create a binary image (black and white) with the edges black and rest white. Be careful of your conventions used to determine what are edges. This may seem primitive, but thats just the way i think :P
    -fastrike

  • How to retain the same resolution while croping a tiff image using jai api

    Hi all,
    I have designed a program to crop a tiff image.But after croping the tiff,the resultant file resolution is not the same as the original source file.
    In the program,the source file Nadeshiko_v1_02.tif has the resolution(X) of 1200 DPI and resolution(Y) has 1200 DPI pixels.
    But after croping the resolution of output file is 100 DPI.
    Please give me some idea on how to retain the same resolution.
    <code>
    package jai;
    import java.awt.Frame;
    import java.awt.image.RenderedImage;
    import java.awt.image.renderable.ParameterBlock;
    import java.awt.image.renderable.RenderableImage;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import javax.imageio.*;
    import javax.imageio.stream.ImageOutputStream;
    import javax.media.jai.Interpolation;
    import javax.media.*;
    import javax.media.jai.JAI;
    import javax.media.jai.PlanarImage;
    import javax.media.jai.RenderedOp;
    import javax.media.jai.widget.ScrollingImagePanel;
    import com.sun.media.jai.codec.FileSeekableStream;
    import com.sun.media.jai.codec.SeekableStream;
    import com.sun.media.jai.codec.TIFFEncodeParam;
    import javax.media.jai.OperationDescriptorImpl;
    import java.io.*;
    import java.util.Iterator;
    import javax.media.jai.operator.*;
    // import javax.media.jai.widget.ScrollingImagePanel;
    public class crop {
              /** The main method. */
    public static void main(String[] args) {
    /* Validate input. */
    /* if (args.length != 1) {
    System.out.println("Usage: java JAISampleProgram " +
    "input_image_filename");
    // System.exit(-1);
    float a=(float) 70.3;
    float b=(float) 70.4;
    float c=(float) 3100.3;
    float d=(float) 5522.4;
    * Create an input stream from the specified file name
    * to be used with the file decoding operator.
    String TIFF="TIFF";
    FileSeekableStream stream = null;
    try {
         stream = new FileSeekableStream("D:\\tif images\\Nadeshiko_v1_02.tif");
    // stream = new FileSeekableStream("D:\\tif images\\Nadeshiko_v1_01.jpg");
    } catch (IOException e) {
    e.printStackTrace();
    System.exit(0);
    // Load the source image from a Stream.
    RenderedImage im = JAI.create("stream", stream);
    RenderedImage image2= CropDescriptor.create(im, a, b, c, d, null);
    ScrollingImagePanel panel = new ScrollingImagePanel(image2, 100, 100);
    // Create a frame to contain the panel.
    Frame window = new Frame("JAI Image Cropping");
    window.add(panel);
    window.pack();
    // window.show();
    // Define the source and destination file names.
    // String inputFile = "D:\\tif images\\Nadeshiko_v1_05.tif";
    String outputFile = "D:\\tif images\\Nadeshiko_v1_04.tif";
    // Save the image on a file. We cannot just store it, we must set the image encoding parameters
    // to ensure that it will be stored as a tiled image.
    TIFFEncodeParam tep = new TIFFEncodeParam();
    tep.setWriteTiled(true);
    tep.setTileSize(80,80);
    JAI.create("filestore",image2,outputFile,"TIFF",null);
    try {
                   stream.close();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    </code>
    Thanks,
    Sanat Meher

    Try the following,
    TIFFEncodeParam tep = new TIFFEncodeParam();
    // Create {X,Y}Resolution fields.
    TIFFField fieldXRes = new TIFFField(0x11A, TIFFField.TIFF_RATIONAL,
                                        1, new long[][] {{DPI_X, 1}});
    TIFFField fieldYRes = new TIFFField(0x11B, TIFFField.TIFF_RATIONAL,
                                        1, new long[][] {{DPI_Y, 1}});
    tep.setExtraFields(new TIFFField[] {fieldXRes, fieldYRes});

  • Export to Excel is not working for List View Web Part after filtering using Query String parameters in SharePoint 2010

    Hi, 
    I am filtering SharePoint list view web part based on Query string parameter and I am doing Export to Excel by using following code.
    <a href="#" onclick="javascript:window.location='../_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=0DC67399-BE11-48F3-ADFC-E911FB8B5845&View=54671412-3EFE-4281-835A-9EF747AE774E&CacheControl=1'"><img
    alt="Excel" src="/_layouts/images/icxlsx.gif" border="0"/>&nbsp;Export to Excel</a>
    Issue: Able to do Export to Excel when there are no filters applied on list view web part but if applied filters on web part and do export to excel , only header fields are displaying in the excel sheet.
    I don't know why owssvr.dll is behaving like that .
    Please share your ideas.
    Thanks in Advance.

    Hi,
    According to your post, my understanding is that you wanted to create hyperlink to export to excel.
    The URL to execute the export is as follows:
    {Site URL}/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List={List GUID}&View={View GUID}&CacheControl=1
    After getting the GUID, you  need to “decode” the list GUID.
    Replace %7B with {
    Replace %2D with –
    Replace %7D with }
    More information:
    Create Link to Export Library Contents to Excel
    SharePoint - Create a link to export to Excel
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Filters used in a query

    Hi,
    Is there anyway we can know what filters are being used in a query. I am using 2 variables to filter my query.But the report gives me this warning "Invalid filter on ZCODE: Filter changed". This is a display hierarchy with no variables on this infoobject. Can anyone  explain why it is giving me this warning and how I can view the filters when I run the query. All your answers will be rewarded.
    Thanks,
    Kal

    > Go to Query Properties - Variable Sequence - U shud
    > see all the variables here.
    > Do u have a Hier Variable set up for ZCODE.
    There is no variable set for ZCODE. It is just a display hierarchy. But the warning shows me a filter on ZCODE. Is it anyone of the dynamic filters which pop up in the warning messages(This is just a guess). I dont understand how the filters get assigned for infoobjects which do not have any variables associated with it.

  • Please help me identify the filters used in this image

    Hey there folks!
    I currently have a contract with a lingerie company, who want me to make a collage quite similar to the following image, which they have provided me with. Mine will be obviously much different, but the same idea...a little boutique shop front but with Paris in the backgrounds etc with one colour and lots of glowing lights and stars.
    What I am wondering, as I am quite new to Photoshop collages (I usually use it for retouching images etc), is how was this image put together, what kind of effects were used? How many different images have been used in this one?
    So far I have a street lamp, a shop front, a girl, and an image of Paris at night. I'm especially unsure about how to do that circular gradient around the image - and the company are absolutely mad for it!
    Thanks so much folks!

    What I am wondering, as I am quite new to Photoshop collages (I usually use it for retouching images etc), is how was this image put together, what kind of effects were used? How many different images have been used in this one?
    The image is a bit small to judge, but it could have been shot with the lamp and storefront as props on a reflective flooring and even the background might have been in the studio – the last one I doubt, though, because it does not reflect in the floor.
    Anyway, if you do make a montage I personally find it important to
    • combine the parts as Smart Objects,
    • do the object-clipping with Layers Masks in the Smart Objects and
    • use Adjustment Layers for color corrections.
    As for
    glowing lights and stars
    stars are fairly easily faked (if one has low enough standards) with a white Solid Color Layer set to Blend Mode Dissolve and the Opacity and Fill Opacity reduced accordingly; for different sizes convert to Smart Object, duplicate and upscale.
    Glows can be done various ways. For example making a SO-duplicate, using the Filters Maximum and Gaussian Blur and setting the layer to Blend Mode Screen (if necessary use the Blend If-settings to limit the effect).

Maybe you are looking for