Solved

Edge Preserving Smoothing using Java

Posted on 2002-06-16
13
433 Views
Last Modified: 2008-02-07
Hi,

I am trying to impliment the "mode", median" and "k-nearest neighbour" edge preserving smoothing filters in Java but I am just a beginner in Java. Would anybody be able to help me out with these??

Also, I want to write a Java program to do basic block truncation coding on a 256*256 image with 256 grey levels. I want to be able to store the 2 grey level values for each 4*4 block in two 64*64 arrays. Could anyone help me with this??

Finally, I want to write a Java program that will work on an image array with 16 grey levels to do the following:
-using an appropriate length natural code for the grey levels, and binary bit-plane coding, compute the total number of runs in each bit plane
-using an appropriate length Gray code for the grey levels, and binary bit-plane coding, compute the total number of runs in each bit plane.

I would really appreciate any help in this!

Regards,
Guster
0
Comment
Question by:Guster
  • 3
  • 3
  • 3
  • +3
13 Comments
 
LVL 9

Accepted Solution

by:
yongsing earned 100 total points
ID: 7082796
You probably can use Java 2D to do those stuff. Java 2D is part of the core Java JDK. You will need to pick up a book on Java 2D though. Beside Java 2D, you can also use the Java Advanced Imaging (JAI) API, which is a separate library from Sun:

http://java.sun.com/products/java-media/jai/
0
 
LVL 92

Expert Comment

by:objects
ID: 7082805
>  am trying to impliment the "mode", median" and "k-
> nearest neighbour" edge preserving smoothing filters

Can you post what you've done so far?
0
 
LVL 4

Expert Comment

by:delphi3
ID: 7084094
listening
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Guster
ID: 7084487
I haven't really got anything done on the image processing stuff as I'm new to this field!

Regards,
Guster
0
 
LVL 9

Expert Comment

by:yongsing
ID: 7084829
Then you'll have to read up on Digital Imaging Processing.
0
 
LVL 9

Expert Comment

by:Ovi
ID: 7085471
Use JAI,will do'it for you in a very simple manner.
0
 

Author Comment

by:Guster
ID: 7141133
Hi again, I've got a book on Digital Image Processing by Nick Efford which was recommended to me, but theres nothing in it that relates to edge preserving smoothing. I've also checked out the JAI stuff but it doesn't have any source code that I could look at that would enable me to understand how it works??
I've also searched the Internet widely and have found sites that explain the idea behind Edge Preserving Smoothing but I can't find any Java code anywhere that illustrates how it is done??
I know how to do Convolution in Java if that is of any help?? Below is some Java code:


public void convolve(IntImage imageIn, int[][] template) {
       
 IntImage imageOut = new IntImage(ImageSize,ImageSize);
 IntImage src = new IntImage(ImageSize, ImageSize);
  src = imageIn;
       
  int nMaskRows = template.length;
  int nMaskCols = template[0].length;
       
int rBorder = nMaskRows / 2;  // integer division
int cBorder = nMaskCols / 2;
int sum;

for (int r = 0; r < (ImageSize - nMaskRows + 1); r++) {
  for (int c = 0; c < (ImageSize - nMaskCols + 1); c++) {
  sum = 0;
       for (int mr = 0; mr < nMaskRows; mr++) {
           for (int mc = 0; mc < nMaskCols; mc++) {
           sum += imageIn.pixels[r+mr][c+mc] * template[mr][mc];
           }//for mc
        }//for mr
             
   imageOut.pixels[r+rBorder][c+cBorder] = sum;
           
  }//forc
}//forr
         
display(imageIn, imageOut);
         
}//convolution

Regards,
Guster
 


0
 
LVL 9

Expert Comment

by:yongsing
ID: 7142213
You can do convolution with Java 2D and JAI. All you need is to supply the convolution mask. You don't have to implement the algorithm yourself.
0
 
LVL 9

Assisted Solution

by:Ovi
Ovi earned 100 total points
ID: 7142658
0
 
LVL 9

Expert Comment

by:Ovi
ID: 7142685
Also you can subscribe to JAI discussion group (highly active) and post more questions. The URL : http://archives.java.sun.com/jai-interest.html 
The email : JAI-INTEREST@JAVA.SUN.COM
0
 

Author Comment

by:Guster
ID: 7174599
Hi again,

I'm working on the smoothing filters, I think I've an idea about how to do them. Does anyone know how to compute the number of runs in a bit plane?? I know how to get the average wordlength. This is shown in the program below:    


public void natural(double [] prob){
               
 int count = 0;
 int code = 0;
 double temp = 0;
 double averageWordLength = 0;
               
for(int i = 0; i < prob.length;i++){
  if(prob[i] != 0){
     count++;
     System.out.println(i + " " + prob[i]);
  }//if          
}//for
                   
if(count<3){
code = 1;
}
else if((count>2)&&(count<5)){
code = 2;
}
else if((count>4)&&(count<9)){
code = 3;
}
else if((count>8)&&(count<17)){
code = 4;
}
else if((count>16)&&(count<33)){
code = 5;
}
else if((count>32)&&(count<65)){
code = 6;
}
else if((count>64)&&(count<129)){
code = 7;
}
else if((count>128)&&(count<257)){
code = 8;
}
               
System.out.println("Number of GreyLevels : " + count);
averageWordLength= code;
System.out.println("Average length of word for natural code: " + averageWordLength);    
System.out.println("Average length of word for gray code: " + averageWordLength);    

}//natural


Regards,
Guster
               
               



0
 
LVL 35

Expert Comment

by:girionis
ID: 8860428
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this
question is:

- split points between yongsing and Ovi

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

girionis
Cleanup Volunteer
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unhandled exception type Exception 18 52
mysql jsp example issue 32 75
Java Inheritance super keyword use 8 38
Delete .class files at every compile 4 24
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video teaches viewers about errors in exception handling.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question