[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

convert picture pixels to matrix array- 2-D DCT in Java

Posted on 2008-02-02
18
Medium Priority
?
4,106 Views
Last Modified: 2013-11-25
Hi
I need to write Java Applet code  for 2-D DCT (Discrete cosine transform) something  like "dctdemo" in Matlab.

I need to have one original image (image for compressing ) , one result image (compresed  image). When i click button i want  to  displayed result image on the screen from original (compressed  with selected quality ex. from 1-100).

How can I convert picture pixels to matrix array,calculate them with  formula and draw array in to result picture??? or the procedure is different??  

So please give me java applet code for this or code for converting pixels, also i need code for drawing pictures from matrix array.


Thank you

 
eda2155809a0e714e7c8d327e6e108df.png
0
Comment
Question by:nikola_mk
  • 9
  • 9
18 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 20808567
Have a look at http://people.csail.mit.edu/koen/PVEM.java and the code beginning with the comment:

"// Get access to the pixel data"
0
 

Author Comment

by:nikola_mk
ID: 20808937
Thank you CEHJ. but i need pixels in matrix( [][] ) not in single array. Do you see formula X(k1,k2)???
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20809316
>>i need pixels in matrix( [][] ) not in single array.

That's not a problem - just divide it up into matrix[image.height][image.width]

>>Do you see formula X(k1,k2)???

Yes
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 

Author Comment

by:nikola_mk
ID: 20809459
Hi CHEJ

Matrix must luck like in this image

[image.height][image.width] are constant values

Examp. i want to see pixel in 2-nd row and 3-col : mat[2,3] and change it with my formula, and save in to the new matrix array. and on the end draw the new array on new picture!!!

Now i think that you understand  me.

Sorry for my english

images.jpg
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20809533
In that case, unpack it into

int[][] matrix = new int[8][8];

That would of course mean that your image has 64 pixels - is that the case?
0
 

Author Comment

by:nikola_mk
ID: 20814049
CHEJ

function getPixels fill one dimensional array, i'm locking for matrix. in your example rgbArray  is one dimensional array!!!
[1 2 3 4 5 62 12 1 4 56] not like this!!!!


Thanks
0
 

Author Comment

by:nikola_mk
ID: 20814085
I need something that luck like this:

for i=0 to height do
  for j=0 to with do
     matrih[i,j]= pic.getPihelFromPicture(i,j)
      }
   }
This is pseudo  code
But function getPihelFromPicture is important???
0
 

Author Comment

by:nikola_mk
ID: 20814134
Or how can I convert 1d array to 2d array(matrix)???
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 750 total points
ID: 20814195
for (int i = 0; i < height;i++) {
      for(int j = 0; j < width;j++)
                 matrix[i,j]= oneDArray[i * width + j];
      }
}
0
 

Author Comment

by:nikola_mk
ID: 20822350
CEHJ thank you for this,
Can you tell me how can I display image from PC in to the BufferedImage ??
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20822363
You can add the image to a label

guiContainer.add(new JLabel(new ImageIcon(imageByteArray)));
0
 

Author Comment

by:nikola_mk
ID: 20841774
CEHJ:can you give me code for assign image from PC to bufferedimage!!!
How can i tell to the bufferedimage, witch image on PC do I put in bufferedimage!!for geting pixels


I am new in java!!


Thank you !!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20841849
BufferedImage bi = javax.imageio.ImageIO.read(new File("x.jpg"));
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20926420
:-)
0
 

Author Comment

by:nikola_mk
ID: 20927463
;)
CEHJ if you can please tell me who are library (imports) for this:
   BufferedImage bi = javax.imageio.ImageIO.read(new File("x.jpg"));

Thak you!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20927512
java.io.BufferedImage bi = javax.imageio.ImageIO.read(new java.io.File("x.jpg"));
0
 

Author Comment

by:nikola_mk
ID: 20927609
InputStream in =  
              getClass().getResourceAsStream("image.jpg");

            BufferedImage bi = javax.imageio.ImageIO.read(in);

I use this code, but where image.jpg can be placed ???
in working directory? or?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20927961
Anywhere you want. That one is in the current directory
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

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

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

607 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