Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to separate RGB chanels? #97

Open
hackintoshrao opened this issue Feb 28, 2017 · 1 comment
Open

How to separate RGB chanels? #97

hackintoshrao opened this issue Feb 28, 2017 · 1 comment

Comments

@hackintoshrao
Copy link

Here is the C++ equivalent to separate a R/G/B channel.

Mat src = imread("img.png",CV_LOAD_IMAGE_COLOR); //load  image

Mat bgr[3];   //destination array
split(src,bgr);//split source  

//Note: OpenCV uses BGR color order
imwrite("blue.png",bgr[0]); //blue channel
imwrite("green.png",bgr[1]); //green channel
imwrite("red.png",bgr[2]); //red channel

How to achieve this in Go OpenCV?

@lbeeon
Copy link

lbeeon commented Mar 14, 2017

Hope help

	for x := 0; x < img.Width(); x++ {
		for y := 0; y < img.Height(); y++ {
			channels := img.Get2D(x, y).Val()
			fmt.Printf("B:%d, G:%d, R:%d, A:%d \n", uint8(channels[0]), uint8(channels[1]), uint8(channels[2]), uint8(channels[3]))
		}
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants