Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Image Puzzle
#1
Hi, i am trying to solve this problem,

I have a test image (A) , this  image is the scrambled form of original image (O).

The goal is to determine the number in the scrambled image.

some details are

   1- orignal image has been  scrambled with the Mersenne Twister with 2 as seed number.
   2- flatten of numpy is used to conver the  image (two-dimension) to a (one-dimension) array.
   3- also function shuffle of random  (we did not utilize the numpy shuffle) to shuffle a list of numbers [0, 1, 2, …, n-1] , here N is equal to pixels in the image.
   4- The list shuffled is used to assign the pixels in the scrambled image like Y[i] = X[shuffled[i]] for all i in [0, 1, 2, …, n-1].


Image Url : https ://ibb.co/f0PGna

The original task is in python but due to my skills in java I am trying to solve this problem in java.

Starting from point 3 , I generated a list equal to pixels in the image and shuffled it, and while iterating the list i assign the pixels from the scrambled image, which did not delivered the req results.

Please if you can guide me, so i can solve this problem.
Reply
#2
(May-29-2017, 08:38 PM)Digitalchemist Wrote: I generated a list equal to pixels in the image and shuffled it, and while iterating the list i assign the pixels from the scrambled image, which did not delivered the req results.
Please post fully runnable (though minimal, 5-10 lines of) code that reproduces the problem, along with example input, the actual output, and the desired output.
Reply
#3
Hi, i am trying to solve this problem with above defined rules.

		BufferedImage image = ImageIO.read(file);
		Color[][] colors = new Color[image.getWidth()][image.getHeight()];

		int width = image.getWidth(); 
		int height = image.getHeight();
		
		List<Integer> cNumbers = new ArrayList<>();
		int cCount = 0;
		for (int x = 0; x < width; x++) {
			for (int y = 0; y < height; y++) {
				colors[x][y] = new Color(image.getRGB(x, y),true);
				//System.out.println(colors[x][y].getRGB());
				cNumbers.add(image.getRGB(x, y)*-1);
			}
		}
		
		

		List<Integer> numbers = new ArrayList<>();
		for (int i = 0; i < width*height; i++) {
			numbers.add(i);
		}
		Collections.shuffle(numbers);
		
		
		int mCount = 0;
		for (int x = 0; x < width; x++) {
			for (int y = 0; y < height; y++) {
				image.setRGB(x, y, cNumbers.get(numbers.get(mCount++)));
			}
		}
		ImageIO.write(image, "png", new File("D:/Store/testing.jpg"));
		
Reply
#4
A couple key problems here:
We're not going to help with Java.
You didn't say what your problem was, provide sample input(s), or anything other than Java code.

If you're struggling with problem solving, especially in a language other than Python, you're really in the wrong place. You could still get an answer but you shouldn't bank on it. And if you're really going to put Java here then you still need to show your best-effort Python. And if you found a SO post that's similar to what you want, you could at least be adapting that.
Reply
#5
(May-31-2017, 12:01 AM)Digitalchemist Wrote: BufferedImage image = ImageIO.read(file);
Types? Semicolons? Do you know where you are right now?
Reply
#6
The problem is simple, the task is to identify the number in the image https://ibb.co/f0PGna .

The image is scrambled, we have to unscrambled to find the original image. using above rules.

i.e

1- orignal image has been scrambled with the Mersenne Twister with 2 as seed number.
2- flatten of numpy is used to conver the image (two-dimension) to a (one-dimension) array.
3- also function shuffle of random (we did not utilize the numpy shuffle) to shuffle a list of numbers [0, 1, 2, …, n-1] , here N is equal to pixels in the image.
4- The list shuffled is used to assign the pixels in the scrambled image like Y[i] = X[shuffled[i]] for all i in [0, 1, 2, …, n-1].
Reply
#7
You need to show your attempt, in Python, and we can help get you unblocked wherever you are with it. But you have to give it a try, we're not going to do your homework for you. This is three posts in a row from you where you're not helping us to help you, in spite of having been told what to do better.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  8 puzzle game aliyark145 4 10,698 May-30-2020, 05:54 PM
Last Post: Alkis
  A sign-Reversal Puzzle HY2000 2 2,460 Dec-05-2019, 11:55 AM
Last Post: HY2000
  Cross word puzzle solve using python constraint library aliyark145 1 3,287 Nov-29-2018, 10:53 AM
Last Post: Larz60+
  Simple Eight-Puzzle not working! BenjaminDJ 2 3,162 May-04-2018, 12:17 PM
Last Post: BenjaminDJ
  Magic Square Puzzle Harnick 1 4,874 Aug-09-2017, 04:51 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020