image processing

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2007
Posts: 31
Reputation: gauravmishra has a little shameless behaviour in the past 
Solved Threads: 0
gauravmishra gauravmishra is offline Offline
Light Poster

image processing

 
0
  #1
Feb 28th, 2008
hi
i want to know that what does the scale() method of AffineTransform do
i mean when we reduce the size of a image does this transform reduces the number of pixels or something else .........
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,273
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 494
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: image processing

 
0
  #2
Feb 28th, 2008
Yes if you do down scale, function will reduce number of pixels and work out colour for each remaining pixel. Where if you scale up (enlarge) it will just spread the colour difference from pixel one to pixel two on the extra pixel received from enlragment
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 31
Reputation: gauravmishra has a little shameless behaviour in the past 
Solved Threads: 0
gauravmishra gauravmishra is offline Offline
Light Poster

Re: image processing

 
0
  #3
Feb 28th, 2008
but when i tried to downscale an image and when i use .getHeight() and getWidth() on the modified image
it shows the older values.
that is i uses 800x800 image
and scale(0.5,0.5);
but still
height=800
width=800
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 31
Reputation: gauravmishra has a little shameless behaviour in the past 
Solved Threads: 0
gauravmishra gauravmishra is offline Offline
Light Poster

Re: image processing

 
0
  #4
Feb 28th, 2008
does this scale also works with black and white images
ie TYPE_BYTE_INDEXED
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,515
Reputation: Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future 
Solved Threads: 523
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: image processing

 
0
  #5
Feb 28th, 2008
Scaling the transform does not reduce the size of the Image object itself.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 31
Reputation: gauravmishra has a little shameless behaviour in the past 
Solved Threads: 0
gauravmishra gauravmishra is offline Offline
Light Poster

Re: image processing

 
0
  #6
Feb 28th, 2008
this is wat i want to do
i have arbitrary sized small images of characters say of size 20x13 or 17x9 i want to convert these images to 10x10 how can i do this.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,515
Reputation: Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future 
Solved Threads: 523
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: image processing

 
0
  #7
Feb 28th, 2008
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 31
Reputation: gauravmishra has a little shameless behaviour in the past 
Solved Threads: 0
gauravmishra gauravmishra is offline Offline
Light Poster

Re: image processing

 
0
  #8
Feb 29th, 2008
i am dealing with black and white images and when i tried scale them what i got was small 10x10 boxes filled with black colour.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 31
Reputation: gauravmishra has a little shameless behaviour in the past 
Solved Threads: 0
gauravmishra gauravmishra is offline Offline
Light Poster

Re: image processing

 
0
  #9
Feb 29th, 2008
i used the following code



public void actionPerformed(ActionEvent e)
{
int i,j,k,w,h;
double w_scale=1.0,h_scale=1.0;
drawimage=2;

byte[] comp = {0 , -1};
IndexColorModel cm = new IndexColorModel(2,2,comp,comp,comp);
BufferedImage temp1=new BufferedImage(15,15,BufferedImage.TYPE_BYTE_INDEXED,cm);
for(k=0;k<characters.size();k++)
{
BufferedImage temp=(BufferedImage)characters.get(k); //characters is ArrayList
w=temp.getWidth();
h=temp.getHeight();
if(w>=15 && h>=15)
{
w_scale=15/w;
h_scale=15/h;
}
else if(w<15 && h>=15)
{
w_scale=1.0;
h_scale=15/h;
}
else if(w<15 && h<15)
{
h_scale=15/h;
w_scale=1.0;
}
else if(w>=15 && h<15)
{
w_scale=15/w;
h_scale=15/h;
}
AffineTransform t=new AffineTransform();

t=AffineTransform.getScaleInstance(w_scale,h_scale);
Graphics2D g=temp1.createGraphics();
g.drawImage(temp,t,null);

g.dispose();


small_list.add(temp1);
repaint();
}
}
Last edited by gauravmishra; Feb 29th, 2008 at 2:20 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,273
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 494
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: image processing

 
0
  #10
Feb 29th, 2008
Did it work or you having some problems with it?

PS: When posting code please use tags. In advanced options press hash sign "#" and that will automaticaly insert these tags for you. Just simple place your code between them
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 890 | Replies: 10
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC