{"id":19135512,"url":"https://github.com/acgeospatial/beginners_sat_opencv","last_synced_at":"2025-10-13T11:04:51.041Z","repository":{"id":108526669,"uuid":"94673217","full_name":"acgeospatial/beginners_sat_openCV","owner":"acgeospatial","description":"Beginners guide to interactive manipulation of satellite data with open cv","archived":false,"fork":false,"pushed_at":"2018-01-15T09:48:41.000Z","size":906,"stargazers_count":10,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-13T11:03:17.322Z","etag":null,"topics":["colours","notebook","opencv","python","rgb","satellite-data"],"latest_commit_sha":null,"homepage":"http://www.acgeospatial.co.uk/","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/acgeospatial.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-18T07:50:47.000Z","updated_at":"2024-12-18T05:53:54.000Z","dependencies_parsed_at":"2023-04-28T11:35:46.408Z","dependency_job_id":null,"html_url":"https://github.com/acgeospatial/beginners_sat_openCV","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/acgeospatial/beginners_sat_openCV","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acgeospatial%2Fbeginners_sat_openCV","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acgeospatial%2Fbeginners_sat_openCV/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acgeospatial%2Fbeginners_sat_openCV/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acgeospatial%2Fbeginners_sat_openCV/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acgeospatial","download_url":"https://codeload.github.com/acgeospatial/beginners_sat_openCV/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acgeospatial%2Fbeginners_sat_openCV/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014750,"owners_count":26085593,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["colours","notebook","opencv","python","rgb","satellite-data"],"created_at":"2024-11-09T06:30:42.469Z","updated_at":"2025-10-13T11:04:51.024Z","avatar_url":"https://github.com/acgeospatial.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# beginners_sat_openCV\nBeginners guide to interactive manipulation of satellite data with open cv\n\n## Scripts\n\n[demo1.py](https://github.com/acgeospatial/beginners_sat_openCV/blob/master/demo1.py) - script to display image and right and left click to display information about colours / row \u0026 column\n\n[demo2.py](https://github.com/acgeospatial/beginners_sat_openCV/blob/master/demo2.py) - script to plot a point (in red) on image and draw a line (in black) between points\n\n[demo3.py](https://github.com/acgeospatial/beginners_sat_openCV/blob/master/demo3.py) - script to display a new window containing the clicked RGB colour using interactive opencv\n\nUpdate Jan 2018 -- \nI have written up a Guide to using OpenCV and Satellite Iamgery using Juypter Notebooks on my blog http://www.acgeospatial.co.uk/jupyter-notebooks-and-satellite-imagery/\n\nScript is here [openCV_simple](https://github.com/acgeospatial/beginners_sat_openCV/blob/master/OpenCV_Display.ipynb) - intro to view sat images in notebooks. Have a go with your own images\n\nEnd update ---\n\n## Blog\n\nread below for blog post from 18th June 2017 (using [demo1.py](https://github.com/acgeospatial/beginners_sat_openCV/blob/master/demo1.py))\n\nhttps://www.linkedin.com/pulse/beginners-guide-user-interaction-opencv-python-satellite-andrew-cutts\n\n![alt tag](http://www.acgeospatial.co.uk/wp-content/uploads/2017/06/Title.png)\n\n\n# Beginners guide to user Interaction with OpenCV in Python\nPosted on 18th June 2017\n\nI have been working with OpenCV for a while now and I still find the speed of results very impressive. It makes for a compelling case for its use in image processing. Computer Vision, at least to me, represents such an incredible opportunity for Remote Sensing specialists as well as non-specialists. I have been meaning to write a beginners guide for a while now and basing it around user interaction seems to be an excellent introduction to OpenCV.\nInstalling OpenCV\n\nYou are going to need Python (either Python 3 or Python 2.7) installed on your computer. I generally use Python 2.7 and OpenCV 3.2. Here is a guide to installing OpenCV on windows; have patience it’s worth it!\n\nhttp://docs.opencv.org/3.2.0/d5/de5/tutorial_py_setup_in_windows.html\n\nIf you are successful, calling import cv2 from a Python GUI should return no errors.\n\nStart by opening an image and viewing it\n```python\nimport cv2\nimg = cv2.imread('yourimage.jpg')\ncv2.imshow('original', img)\ncv2.waitKey(0)\ncv2.destroyAllWindows\n```\n\nThis should be enough to view the image… save the file as xxx.py and run it. For this example I am using a clipped Sentinel2 image of Iran. If I have lost you and you don’t know how to run a Python script this is an excellent guide.\n\n![alt tag](http://www.acgeospatial.co.uk/wp-content/uploads/2017/06/sentinel2-768x481.jpg)\n\nBy pressing escape you will close all windows, or in this case the image window.\n\n## Create an event handler\n\nDon’t be put off, this is much simpler than you may think. First, build a function to do something when the mouse is clicked. Let’s return the x,y (rows, columns) of the image.\n```python\ndef click_event(event, x, y, flags, param):\n    if event == cv2.EVENT_LBUTTONDOWN:\n        print x, y\n```\n        \nYou have to parse the 5 arguments (event, x, y, flags, param) for opencv to recognise the event (line 1). Line 2 says if the event is a left mouse click then print to the terminal x and y (line 3). Add this to the top of the script (just after the import cv2 line).\n\nFinally add this line between lines “cv2.imshow(‘original’, img)” and “cv2.waitKey(0)”\n```python\ncv2.setMouseCallback(\"original\", click_event)\n```\n\nCheck the cmd prompt: you should see x,y printed.\n\nFinally let’s print the RGB values onto the image after a right mouse click\n\nAdd this code to the def click_event\n```python\nif event == cv2.EVENT_RBUTTONDOWN:\n        red = img[y,x,2]\n        blue = img[y,x,0]\n        green = img[y,x,1]\n        print red, green, blue ### prints to command line\n        strRGB = str(red) + \",\" + str(green) + \",\" +str(blue)\n        font = cv2.FONT_HERSHEY_SIMPLEX\n        cv2.putText(img,strRGB,(x,y), font, 1,(255,255,255),2)\n        cv2.imshow('original', img)\n```\n\nWhat is happening here? In lines 2,3\u00264 we are getting the red, green and blue values from the image. I have ordered them in RGB, but notice the values in the square brackets – the 3rd value is the colour value (OpenCV works in BGR colour space hence the ordering). Line 4 prints the values to the cmd prompt, line 5 creates a string out of these values, eg “255,0,255” – this is assigned to the variable strRGB. Line 6 assigns the font to use and line 7 is where text is assigned.\n\nI will try and make a bit more sense of line 8: cv2.putText takes 7 arguments above but what do these mean?\n\nimg – this is the image we are working with\n\nstrRGB – this is the text we want to print\n\n(x,y) – this is the location we are going to put the text\n\nfont – this is the image font; we assigned it in line 6, above\n\n1 – this is the scale factor, we are setting it to 1 in this case\n\n(255,255,255) – this is the colour of the text, in this case white\n\n2 – this is the text thickness.\n\nI hope that is clear. If not, have a look at the official documentation.\n\nIf you run all this code then hopefully when you right click the RGB values will start to appear on the screen.\n\n![alt tag](http://www.acgeospatial.co.uk/wp-content/uploads/2017/06/Title.png)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facgeospatial%2Fbeginners_sat_opencv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facgeospatial%2Fbeginners_sat_opencv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facgeospatial%2Fbeginners_sat_opencv/lists"}