Hi everyone! I am working on a variation to the princeton.edu PhotoMagic LFSR problem found here: http://www.cs.princeton.edu/courses/archive/fall09/cos126/assignments/lfsr.html. Here is my issue. I know that my Random Bit Generator is working correctly as I have extensively tested it with the provided data. Somewhere in my PhotoMagic code, I am messing something up. The encrypted image should look like this:
but instead I am getting this:
What am I doing wrong? Here is my code:
Any help would be greatly appreciated!
Thanks!
Karyn
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35258
7
posted
0
How have you verified that lines 39 to 49 do what you expect them to do?
Probably not since you've pointed it out . But I I just tested those steps and they didn't seem to work any differently than I expected them too. Producing the String representation of the color with
Also, are you expecting RandomBitGenerator.generate(8, GenP, tap) to produce a different number for each pixel? Without its code, I can't tell if it will, but if it doesn't, it seems you are XORing your original image with a solid gray image.
Karyn Mizerski
Greenhorn
Joined: Feb 03, 2013
Posts: 4
posted
1
Bug fixed!! Stevens Miller- you pointing out that I hadn't used sbyte showed me my error. I decided to eliminate my xor method and instead convert the ints red, green, and blue to bytes. Then I used the ^ operator to get a new byte. That did the trick.
Karyn Mizerski wrote:Bug fixed!! Stevens Miller- you pointing out that I hadn't used sbyte showed me my error. I decided to eliminate my xor method and instead convert the ints red, green, and blue to bytes. Then I used the ^ operator to get a new byte. That did the trick.
You guys are awesome! Woo Photo Magic!
Thanks everyone
-Karyn
Glad to help. Do you use an IDE? NetBeans puts a little wavy grey line underneath any variable that isn't used, which is often a flag that should get your attention. Here, sbyte is "used" to hold a value, but NetBeans is smart enough to realize that can't make any difference to the execution of your program, and marks it as "unused" anyway. (NetBeans also correctly points out that the value used to initialize useMe is never used; at lines 30 and 35, you are assigning String references which overwrite the reference assigned in line 23, which you can just leave out.)
Karyn Mizerski
Greenhorn
Joined: Feb 03, 2013
Posts: 4
posted
0
I did use NetBeans, but in my frustration, I was ignoring the gray wavy lines. It helps a lot to have another set of eyes look at it to point out what you're looking over.
Karyn Mizerski wrote:I did use NetBeans, but in my frustration, I was ignoring the gray wavy lines. It helps a lot to have another set of eyes look at it to point out what you're looking over.
Sister, I feel your pain (or your relief, I guess). Before the internet, another set of eyes tended to come along only every few days. Now, you can get them on-demand (and without feeling sheepish later at work).
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.