Don't know how to change images into grayscale under linux

I have already change images into grayscale under windows system by using python ,however when it turned into linux i found it need more code to guide the computer . I may can get the code to achieve but i don’t know how to write the cmake projects. So I beg someone can provide me a executable example on linux for me to learn more.

With my best wishes ,hoping for replaying!

python3 code for linux or windows are the same.
What have you already try?

I tried to turn a image into grayscale with the same code but i don’t know how to achieve it on linux by using cmake to compile them into machine language and the way to execute it.

Show us your code

like this

import cv2
import numpy as np
img = cv2.imread(“1.png”,0)

Yes it works if image exist on disk

you should write (tutorials here ):

import cv2 as cv
import sys
img = cv.imread("starry_night.jpg")
if img is None:
    sys.exit("Could not read the image.")
cv.imshow("Display window", img)
k = cv.waitKey(0)
if k == ord("s"):
    cv.imwrite("starry_night.png", img)
k = cv.waitKey(0)

give full path to image

Thank you!
Let me learn and have a try :grin: