• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

Pixel Information of a Image using Link List

If some one could provide me with a code which extracts the pixel information of an image of any type (Information refers to the RGB Color and the width & Height of the image).  The information of the image should be stored in a Link List.

Regards
0
ZUBAIR
Asked:
ZUBAIR
1 Solution
 
zzynxSoftware engineerCommented:
0
 
Mayank SAssociate Director - Product EngineeringCommented:
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
TimYatesCommented:
>> The information of the image should be stored in a Link List.

Each pixel should be a node in a linked list?

I'm guessing this is a homework assignement, as that makes little or no sense otherwise ;-)
0
 
ZUBAIRAuthor Commented:
Thanks for your comment Tim,

I am learning java and it is obvious that a beginner needs a push or a help from there friends.

Anyhow what i was trying to do was that i need to store information of each and every pixel in a Link list where every pixels properties are saved individually, values of red, green, blue and the axis on which the pixel is lying (X-1, Y-1).

If you need further clarification - please do comment
0
 
TimYatesCommented:
Why don't you just use an array of int?

    int w = img.getWidth() ;
    int h = img.getHeight() ;
    int[] pixels = new int[ w * h ] ;

then, you can get the current X, Y position by modding and dividing like so:

    // loop  through every pixel
    for( int i = 0 ; i < pixels.length ; i++ )
    {
        int x = i % w ;
        int y = i / w ;
    }

and you can get the red, green and blue pixel colours by shifting and bitwise ANDing:

  public final static int getRed(int color) {
    return (color & 0x00FF0000 ) >>> 16 ;
  }

  public final static int getGreen(int color) {
    return (color & 0x0000FF00 ) >>> 8;
  }

  public final static int getBlue(int color) {
    return ( color & 0x000000FF ) ;
  }
0
 
TimYatesCommented:
Storing it in a linked list would lead to using a lot of memory very quickly...  
0
 
ZUBAIRAuthor Commented:
Thanks Tim,

The reason i am doing so is to learn about linklist. If you could guide me - i would be grateful
0
 
TimYatesCommented:
http://www.idevelopment.info/data/Programming/data_structures/java/LinkedList/LinkedList.shtml

is an example of writing your own linked list in java :-)

http://java.sun.com/j2se/1.4.2/docs/api/java/util/LinkedList.html is a java class which does it all for you (which I guess you don't want) :-)

Tim
0
 
TimYatesCommented:
what specific difficulty do you have with your code?

I can't just write a Linked list for you...but I may be able to point out bugs in your existing code...

Tim
0
 
ZUBAIRAuthor Commented:
Thanks a lot Tim :)

I have understood the basic concept of link list - i am a bit confused that how to store 5 different informations in a single node. (Five Different Information are ; RGB Color + X & Y axis of the pixel)

Zubair
0
 
TimYatesCommented:
public class Node
{
    Node next ; // the next node in the list
    int someValue ;
    String someString ;
    double whatever ;
    int anotherInt ;
}

etc..

it's a class...store whatever you want in it :-)

Tim
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now