Jump to content

Binary Classification from a 3x255 array in Python?

TrickyWitcher

Relatively new to Python and have no idea where to start. I've been assigned the task of binary classification of values in 3x255 array from a text file. These values are sets of RGB converted from HSV, where H is the only value that changed, while S and V both stay at 100. The resulting output of going through all of the H values make up the array, which is in RGB. Can someone point me in the right direction, or give me some example code? Attached is a header file that contains the output in an array, if it helps.

HRGB.h

Link to comment
Share on other sites

Link to post
Share on other sites

6 hours ago, M.Yurizaki said:

A few questions:

  • How is the text file formatted?
  • Are you trying to derive H from RGB -> HSV? (Wording in OP is a little confusing to me)

The text file is likely going to be CSV, though I have no specifics.

 

As for the colours, the values will already be in an array, formatted in RGB. I need to write a binary classifier for those.

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, TrickyWitcher said:

The text file is likely going to be CSV, though I have no specifics.

To start here, if you don't know file I/O already, I'd suggest looking at https://docs.python.org/3/tutorial/inputoutput.html. If you're not using Python 3.7, a drop-down menu on the top of the page will let you select the version you are using, though I don't think Python 3.x has changed much.

 

CSV makes it easy, since you can remove the characters you don't need using .replace() and then use a .split() to get each item as a list.

2 hours ago, TrickyWitcher said:

As for the colours, the values will already be in an array, formatted in RGB. I need to write a binary classifier for those.

To convert RGB to HSV: https://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_RGB_to_HSV_used_commonly_in_software_programming

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×