Skip to content

Commit

Permalink
Added Binary Function
Browse files Browse the repository at this point in the history
Produces one dimensional array wih each binary digit as one element.
PS. test.py is an extra file: mostly to be used as an example.

Co-Authored-By: Yashee Sinha <54110843+bluish-y@users.noreply.github.com>
  • Loading branch information
AeishnaKhaund and Bluish-y committed Aug 4, 2020
1 parent cef5668 commit a3f4fd1
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 8 deletions.
Binary file modified .vs/Externally-Randomized-Encryption-Service/v16/.suo
Binary file not shown.
Binary file modified .vs/slnx.sqlite
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified random-sources/stone-positions/__pycache__/randomize.cpython-37.pyc
Binary file not shown.
19 changes: 16 additions & 3 deletions random-sources/stone-positions/randomize.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,22 @@ def __sortArray(self, columnIndex):
sortedArr = self.pts[self.pts[:,columnIndex].argsort()]
return sortedArr

def randomPoints(self):
def __randomDecPoints(self):
# sortArray = self.__sortArray(columnIndex)
cy = np.asarray([p[1] for p in self.__sortArray(0)])
cx = np.asarray([p[0] for p in self.__sortArray(1)])
random_sequence = np.concatenate ([cx,cy], axis=None)
return random_sequence
random_dec_sequence = np.concatenate ([cx,cy], axis=None)
return random_dec_sequence


def randomBinPoints(self):
dec_seq = self.__randomDecPoints()
floored = np.floor(dec_seq)
sequence = []
for element in floored:
binary = bin(int(element))
binary = binary[2:]
sequence += binary
return sequence


12 changes: 7 additions & 5 deletions random-sources/stone-positions/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@
from randomize import *


#example code

N = 360 #reqd. image sq. dimension
T = 90
img_path1 = "C:\\Users\\Aeishna\\Downloads\\marbles.jpg"
img_path2 = "C:\\Users\\Aeishna\\Downloads\\IMG_20200721_121939.jpg"
img_path3 = "C:\\Users\\Aeishna\\Downloads\\marbles2.jpg"
preprocessed = rice_stones_prep(img_path3)
preprocessed = rice_stones_prep(img_path1)
final_img = preprocessed.img_prep(N, T)

detected = stone_detector(final_img)
pts = detected.coordinates()
print(pts)
randomized = randomize(pts)
random_sequence = randomized.randomPoints()
print(random_sequence)
random_sequence = randomized.randomBinPoints()
print(len(random_sequence))



# To compare detection of points

# im_with_keypoints, keypoints = detected.blob_detector(False)
# f, (ax1, ax2) = plt.subplots(1, 2)
Expand Down

0 comments on commit a3f4fd1

Please sign in to comment.