-
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
-
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 http://java.sun.com/docs/books/tutor...ingarrays.html
For Instance:
Code:
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.
-
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?
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks