Solved

Edge Preserving Smoothing using Java

Posted on 2002-06-16
13
428 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Running Jira on Raspberry PI 2? 3 264
Starting to learn JAVA, 7 59
Java array passed to SQL where clause 23 63
map related example 6 36
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
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:

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now