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

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
nikola_mkAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
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
nikola_mkAuthor Commented:
Thank you CEHJ. but i need pixels in matrix( [][] ) not in single array. Do you see formula X(k1,k2)???
0
CEHJCommented:
>>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
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

nikola_mkAuthor Commented:
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
CEHJCommented:
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
nikola_mkAuthor Commented:
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
nikola_mkAuthor Commented:
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
nikola_mkAuthor Commented:
Or how can I convert 1d array to 2d array(matrix)???
0
CEHJCommented:
for (int i = 0; i < height;i++) {
      for(int j = 0; j < width;j++)
                 matrix[i,j]= oneDArray[i * width + j];
      }
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nikola_mkAuthor Commented:
CEHJ thank you for this,
Can you tell me how can I display image from PC in to the BufferedImage ??
0
CEHJCommented:
You can add the image to a label

guiContainer.add(new JLabel(new ImageIcon(imageByteArray)));
0
nikola_mkAuthor Commented:
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
CEHJCommented:
BufferedImage bi = javax.imageio.ImageIO.read(new File("x.jpg"));
0
CEHJCommented:
:-)
0
nikola_mkAuthor Commented:
;)
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
CEHJCommented:
java.io.BufferedImage bi = javax.imageio.ImageIO.read(new java.io.File("x.jpg"));
0
nikola_mkAuthor Commented:
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
CEHJCommented:
Anywhere you want. That one is in the current directory
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.