Solved

Edge Preserving Smoothing using Java

Posted on 2002-06-16
13
429 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java Options in Zimbra Server 2 50
how to see all occupied ports on windows 10 laptop 15 61
spring jars download 1 26
Chrome and Firefox Java 5 23
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…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

813 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

11 Experts available now in Live!

Get 1:1 Help Now