Resizing Array

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Resizing Array

  1. #1
    Join Date
    Feb 2004

    Resizing Array

    Hmm, my previous thread seem to have gone missing. Well, anyway, I have a question on resizing / scalling an array which stores my raster graphic. Why i need this is to later pass this array into a neural network for training.

    What i did was like this.

    1)Get drawing from mouse down

    2)Store in an array of [points][3] where [point][0] is x, [point][1] is y and [point][2] is my mouse up or down

    3)Perform a DDA algoritm to fill in the gaps between the array

    4)Get the bounding box of the draw image to then later create a 2nd array which would store the image as an array of 1's and 0's representing each point

    Now my problem is like this. I would like to scale it to lets ssay a size of 200x200. So I would first calculate the factor and so on. What i dont know how to do is to rescale the array to that size. I would be facing some problems such as if the array is size of 70x50, how woudl i be able to resccale to an odd factor.

    Also, how do i rescale it so that it's porpotional? Any ideas?

    Thannks for ur help in advance

  2. #2
    Join Date
    Feb 2004
    I'll refer to the current array you want to resize as old.

    1. Create a new array, correctly sized.
    2. Copy the old array into the new array using System.arraycopy(). You should be able to copy using that. Checkout

    For Instance:
    System.arraycopy(old, 0, new, 0, old.length);
    That will copy the old array beginning at position 0, into the new array beginning at position 0, copying the total length of the old array.

  3. #3
    Join Date
    Feb 2004
    I think you are misunderstanding me

    Copying the array is least of my problems. I just would like to know how to rescale the array. Urm, should i call it a raster image as now the values are now stored as 1s and 0s. For example the word L might be stored as

    0 0 0 0 0 0 0 0 0 0
    0 0 0 1 0 0 0 0 0 0
    0 0 0 1 0 0 0 0 0 0
    0 0 0 1 0 0 0 0 0 0
    0 0 0 1 0 0 0 0 0 0
    0 0 0 1 0 0 0 0 0 0
    0 0 0 1 0 0 0 0 0 0
    0 0 0 1 1 1 1 1 1 0
    0 0 0 0 0 0 0 0 0 0

    Er, can you see the 1's which form the word "L" up there? So, I've been trying to scale it up for quite some time now. Say the size now is 10 x 9 and i would like to scale it to 30 x 30, what method would i use to accomplish this?

  4. #4
    Join Date
    Feb 2004
    the thread you "lost" is found here:

    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center