Solved

Edge Preserving Smoothing using Java

Posted on 2002-06-16
13
427 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
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:
The viewer will learn how to implement Singleton Design Pattern in Java.

705 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

21 Experts available now in Live!

Get 1:1 Help Now