Results 1 to 10 of 10
Thread: 2D image feature extraction.
- 04-25-2012, 10:10 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 4
- Rep Power
- 0
2D image feature extraction.
Following is the program for 2d image extraction, can anybody plz explain me the first for loop??
/*
*<applet code=HistoGrab.class width=314 height=400>
*<param name=img value=input.jpg>
*</applet>*/
import java.applet.*;
import java.awt.*;
import java.awt.image.*;
public class HistoGrab extends Applet{
Dimension d;
Image img;
int iw,ih;
int pixels[];
int w,h;
int hist[]=new int[256];
int max_hist=0;
public void init()
{
d=getSize();
w=d.width;
h=d.height;
try
{
img=getImage(getDocumentBase(),getParameter("img") );
MediaTracker t=new MediaTracker(this);
t.addImage(img,0);
t.waitForID(0);
iw=img.getWidth(null);
ih=img.getHeight(null);
pixels=new int[iw*ih];
PixelGrabber pg=new PixelGrabber(img,0,0,iw,ih,pixels,0,iw);
pg.grabPixels();
}catch(InterruptedException e){};
for(int i=0;i<iw*ih;i++)
{
int p=pixels[i];
int r=0xff & (p>>16);
int g=0xff & (p>>8);
int b=0xff & (p);
int y=(int)(.33 * r +.56 * g + .11 * b);
hist[y]++;
}
for(int i=0;i<256;i++)
{
if(hist[i]>max_hist)
max_hist=hist[i];
}
}
public void update(){}
public void paint(Graphics g){
g.drawImage(img,0,0,null);
int x=(w-256)/2;
int lasty =h-h * hist[0]/max_hist;
for(int i=0;i<256;i++,x++){
int y=h-h * hist[i]/max_hist;
g.setColor(new Color(i,i,i));
g.fillRect(x,y,1,h);
g.setColor(Color.red);
g.drawLine(x-1,lasty,x,y);
lasty=y;
}
}
}
- 04-25-2012, 12:06 PM #2
Re: 2D image feature extraction.
BB Code List - Java Programming Forum
What's there to explain? Tell us what you understand so we can take it from there.can anybody plz explain me the first for loop?
The for Statement (The Java™ Tutorials > Learning the Java Language > Language Basics)
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 04-25-2012, 12:08 PM #3
Re: 2D image feature extraction.
Isn't that code under copyright? Do you have the author's permission to reproduce it in a public forum?
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 04-25-2012, 01:29 PM #4
Member
- Join Date
- Apr 2012
- Posts
- 4
- Rep Power
- 0
Re: 2D image feature extraction.
Its not that i dnt knw how for loop works, i didn't understand what " (p>>16) " mean, i mean frm where did this 16 and 8 value come frm. and also the values .33,.56 and .11.
- 04-25-2012, 04:49 PM #5
- 04-25-2012, 04:50 PM #6
Re: 2D image feature extraction.
Use proper words.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 04-28-2012, 02:04 PM #7
Member
- Join Date
- Apr 2012
- Posts
- 4
- Rep Power
- 0
Re: 2D image feature extraction.
I have no idea about that, i saw that code in reference book, i didnt know anything about the copyright issues, so to be on safer side please remove this thread.
- 05-01-2012, 08:28 AM #8
Member
- Join Date
- May 2012
- Posts
- 2
- Rep Power
- 0
Re: 2D image feature extraction.
there are 24 bits in p. each of 8 bits contain the values for red,green and blue. you are suppose to extract them.so we and them with 0000FF(1111 1111) which will set the remaining bits to 0.so for red,we are suppose to get the 1st 8 bits,so we shift the 16 bits to right.i.e if the bits are 1101 1101 1110 1110 1001 1001(before shift)it will become 0000 0000 0000 0000 1101 1101 after shift. now we and it with 0000ff so we get the 1st eight bits untouched that is the value for red.
for next step we shift by eight for green
nd in the last step we do it for blue.
Note:0x notifies a hexadecimal number.i.e 0xff = FF= 00ff=0000FF.
- 05-01-2012, 04:29 PM #9
Member
- Join Date
- Apr 2012
- Posts
- 4
- Rep Power
- 0
Re: 2D image feature extraction.
Hey thanks a lot, got my doubts cleared !!
- 05-03-2012, 02:48 PM #10
Member
- Join Date
- May 2012
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
sub query extraction
By mkarthik90 in forum Advanced JavaReplies: 18Last Post: 02-13-2012, 03:00 PM -
green channel extraction
By sarah49 in forum Java 2DReplies: 1Last Post: 01-27-2012, 11:14 AM -
Data Extraction using JAVA
By yap_1991 in forum Advanced JavaReplies: 1Last Post: 06-01-2010, 08:02 AM -
web extraction
By murali in forum NetworkingReplies: 3Last Post: 12-13-2008, 07:10 AM -
Feature extraction from a text file in java. this is used for scoring the sentences
By joe_2110 in forum Advanced JavaReplies: 1Last Post: 02-04-2008, 08:26 PM


LinkBack URL
About LinkBacks
Reply With Quote
.gif)

Bookmarks