?
Solved

Edge Preserving Smoothing using Java

Posted on 2002-06-16
13
Medium Priority
?
439 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +3
13 Comments
 
LVL 9

Accepted Solution

by:
yongsing earned 300 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 300 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

Technology Partners: 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!

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

765 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