Opencv图像核心基本操作(4拆分及合并图像通道)

4.拆分及合并图像通道

我们先来介绍一下通道是什么意思:

简单而言通道就是调色用的色彩,

例如:如果你想让一幅图像偏红,就让红色通道中的灰度值大点就好了。

我们先来看一下结果

这就是拆分完以后三种通道的样子

原图是这个

原图

我们纳闷为啥彩色变成灰白的了呢,这就是问题所在。

因为数字图像本身是一个矩阵,只有我们在图像显示时,可以理解为合并图像时,将BGR三种不同的分量,放入相应的蓝绿红通道中,处理后才会显示彩色图。

一旦我们把不同的分量放入不同的通道后,就会出现下面的情况

就是这个很神奇的感觉,这就是通道的神奇功效~

现在先不放源码,我要去探索新大陆,晚上放源码,顺便说一下为什么会这样。我是Y,拜拜~

# -*- coding:utf-8 -*-
"""
Created on Fri Jan 13 12:24:31 2017

@author: Y

"""

import cv2
import numpy as np

img = cv2.imread("C:\Users\Administrator\Desktop\opencvimg\wtf.png")

b = np.zeros((img.shape[0],img.shape[1]), dtype=img.dtype)
g = np.zeros((img.shape[0],img.shape[1]), dtype=img.dtype)
r = np.zeros((img.shape[0],img.shape[1]), dtype=img.dtype)

b[:,:] = img[:,:,0]
g[:,:] = img[:,:,1]
r[:,:] = img[:,:,2]

img_RGB = img.copy()
img_RGB[:, :, 0] = r
img_RGB[:, :, 1] = g
img_RGB[:, :, 2] = b

img_GRB = img.copy()
img_RGB[:, :, 0] = g
img_RGB[:, :, 1] = r
img_RGB[:, :, 2] = b

merged = cv2.merge([b,g,r])
print merged.strides
print merged



cv2.imshow("Merged", merged)
cv2.imshow('RGB',img_RGB)
cv2.imshow('GRB',img_GRB)
cv2.imshow("Blue", b)
cv2.imshow("Red", r)
cv2.imshow("Green", g)
cv2.waitKey(0)
cv2.destroyAllWindows()
# -*- coding:utf-8 -*-
"""
Created on Fri Jan 13 11:54:33 2017

@author: Y

"""

import cv2
import numpy as np
img=cv2.imread('C:\Users\Administrator\Desktop\opencvimg\wtf.png')
b,g,r=cv2.split(img)
img=cv2.merge(b,g)

cv2.imshow('blue',b)
cv2.imshow("Green", g)
cv2.imshow("Red", r)
cv2.waitKey(0) &0xFF
cv2.destroyAllWindows()

我想说,自己先理解理解,等有空我详细解释

 

《Opencv图像核心基本操作(4拆分及合并图像通道)》有221个想法

  1. It is in reality a great and useful piece of info. I am happy that you shared this useful info with us.
    Please keep us up to date like this. Thank you for sharing.

  2. Oh my goodness! Impressive article dude! Thank you, However I am having troubles with your
    RSS. I don’t understand why I can’t join it. Is there anybody else
    getting similar RSS issues? Anyone who knows the answer will you kindly respond?
    Thanks!!

  3. Pretty nice post. I just stumbled upon your weblog and wished to say that
    I’ve truly enjoyed surfing around yojr blog posts.
    In any case I’ll be subscribing to your rss fewed and I hkpe you write again vsry soon!

  4. I’ve been browsing online greater than 3 hours today, but I never found any fascinating article like yours.
    It’s pretty value sufficient for me. In my opinion, if all webmasters
    and bloggers made excellent content material as
    you probably did, the web will probably be much more helpful than ever before.cheap nhl jerseys China

  5. After I originally left a comment I appear to have clicked the -Notify mme when new comments are
    added- checkbox and now every time a comment is added I get four emails with the same comment.
    Perhaps there is a means you are able to remove me from that service?
    Cheers!

  6. We’re a grup of volunteers and opening a neew scheme iin our community.
    Your website provided us with valuable info to work on. You’ve done a formidable
    job and our entire community will bbe gratesful to you.

  7. We are a group of volunteers and starting a new scheme in our community. Your web site offered us with valuable information to work on. You’ve done a formidable job and our whole community will be thankful to you.

  8. Saved aas a favorite, I love your website! Ahaa, itss pleaxant discjssion onn thhe toppic oof thios piece oof writing aat thi place att thuis webb site, I have read alll
    that, sso att this timee me also commentin aat this place.
    I am suire tjis pokst has touched all the internet viewers,
    iits really realply plasant poost onn buioding upp nnew weeb
    site.

  9. Pretty component to content. I simply stumbled upon your
    site and in accession capital to claim that I acquire actually
    loved account your blog posts. Anyway I will be subscribing on your feeds or
    even I fulfillment you get right of entry to consistently rapidly.

  10. Hey very nice web site!! Guy .. Beautiful
    .. Wonderful .. I will bookmark your website and take the feeds
    additionally? I’m happy to seek out numerous useful info right here in the submit, we’d like develop extra techniques in this regard,
    thank you for sharing. . . . . .

  11. Great post. I used to be checking continuously this weblog and I’m impressed!
    Very useful information specially the closing part :
    ) I take care of such information a lot. I was seeking this particular information for a very lengthy time.
    Thanks and good luck.

  12. I’m really enjoying the theme/design of your site.
    Do you ever run into any internet browser compatibility issues?
    A few of my blog visitors have complained about my
    blog not operating correctly in Explorer but looks great in Firefox.
    Do you have any suggestions to help fix this
    problem?

  13. Unquestionably believe that which you stated. Your favorite justification appeared
    to be on the net the easiest thing to be aware of.
    I say to you, I certainly get annoyed while people consider
    worries that they just don’t know about. You managed to hit the nail upon the top as
    well as defined out the whole thing without having side-effects , people could take a signal.
    Will probably be back to get more. Thanks

  14. Hiya! Quick question that’s entirely off topic.
    Do you know how to make your site mobile friendly? My site looks weird when viewing from my iphone.

    I’m trying to find a template or plugin that might be able to fix this
    issue. If you have any recommendations, please share.
    Cheers!

  15. Greetings from Carolina! I’m bored at work so I decided to check out your blog
    on my iphone during lunch break. I enjoy the info you provide here and can’t wait to take a look when I get home.
    I’m surprised at how fast your blog loaded on my cell phone ..

    I’m not even using WIFI, just 3G .. Anyways, good site!

  16. Very nice post. I just stumbled upon your blog and wanted to
    say that I have really enjoyed browsing your blog posts.
    After all I’ll be subscribing to your rss feed and I hope you write again very soon!

  17. magnificent post, very informative. I wonder why the other experts
    of this sector do not realize this. You must
    continue your writing. I am confident, you have a huge readers’ base already!

  18. I am only commenting to let you understand what a extraordinary encounter my wife’s daughter undergone viewing your blog.
    She came to understand a good number of pieces, which included what it’s
    like to have an ideal coaching mindset to let most people clearly comprehend several multifaceted issues.
    You really surpassed visitors’ desires. Thanks for showing
    these warm and friendly, trustworthy, revealing and even easy tips on that topic to Gloria.

  19. Definitely Ballad of Seo Dong (sadly not as easily accessible with English subs), Queen Seon Duk, Illjimae, and Dong Yi.
    🙂 Sungkyunkwan Scandal was also fun, if people want something more light-hearted.

  20. It’s a pity you don’t have a donate button! I’d most certainly donate to this fantastic blog!
    I guess for now i’ll settle for bookmarking and adding your RSS feed to my
    Google account. I look forward to new updates and will talk about this site
    with my Facebook group. Chat soon!

  21. Excellent goods from you, man. I have understand your stuff previous to and you’re just
    extremely fantastic. I really like what you have acquired here, certainly like
    what you’re stating and the way in which you say
    it. You make it entertaining and you still care for to keep it
    sensible. I cant wait to read far more from you. This is actually a terrific website.

  22. Hello there, just became aware of your blog through Google, and found that
    it is really informative. I’m gonna watch out for brussels.
    I’ll be grateful if you continue this in future.
    A lot of people will be benefited from your writing. Cheers!

  23. magnificent publish, very informative. I wonder why the opposite experts of this
    sector don’t notice this. You must continue your writing.
    I’m sure, you’ve a huge readers’ base already!

  24. Hi, I do believe this is an excellent site.
    I stumbledupon it 😉 I’m going to revisit once again since I saved as a favorite it.
    Money and freedom is the best way to change, may you be rich and continue to
    help others.

  25. Woah! I’m really digging the template/theme of this site.
    It’s simple, yet effective. A lot of times it’s hard to get that “perfect balance” between user friendliness and
    visual appearance. I must say you have done
    a amazing job with this. Additionally, the blog loads extremely quick for me on Firefox.
    Exceptional Blog!

  26. Appreciating the dedication you put into your website and in depth information you present.
    It’s awesome to come across a blog every once in a while that
    isn’t the same old rehashed information. Excellent read!
    I’ve bookmarked your site and I’m including your RSS feeds to my
    Google account.

  27. Do you have a spam problem on this blog; I also am a blogger,
    and I was curious about your situation; we have developed some nice practices and we are looking to exchange solutions with other folks, please shoot me an email if interested.

  28. Woah! I’m really loving the template/theme of this site. It’s simple, yet effective. A lot of times it’s hard to get that “perfect balance” between user friendliness and visual appeal. I must say you’ve done a excellent job with this. Additionally, the blog loads extremely quick for me on Internet explorer. Superb Blog!

  29. Hi there! This article couldn’t be written any better!

    Looking through this post reminds me of my previous roommate!
    He always kept preaching about this. I will forward this information to him.

    Pretty sure he’ll have a great read. Thank you for sharing!

    creditos rapidos sin asnef

  30. After I initially commented I seem to have clicked
    on the -Notify me when new comments are added- checkbox and now each time a comment is
    added I receive four emails with the same comment.

    There has to be an easy method you can remove me from that service?
    Thank you!

    creditos rapidos y seguros

  31. Thanks for the sensible critique. Me and my neighbor
    were just preparing to do some research on this. We got a grab
    a book from our local library but I think I
    learned more from this post. I’m very glad to see such magnificent information being shared freely out there.

  32. Do you have a spam issue on this blog; I also am a blogger, and I was wanting
    to know your situation; many of us have developed some nice methods and we are looking to
    trade techniques with others, why not shoot me an e-mail if interested.

  33. This design is incredible! You certainly know how to keep a reader amused.
    Between your wit and your videos, I was almost moved
    to start my own blog (well, almost…HaHa!) Fantastic job.

    I really loved what you had to say, and more than that, how you presented it.
    Too cool!

  34. I haven’t checked in here for a while because I thought it
    was getting boring, but the last few posts are good quality so I guess I’ll add you back to my
    daily bloglist. You deserve it friend 🙂

  35. I’m really enjoying the design and layout of your site.
    It’s a very easy on the eyes which makes it much more pleasant for
    me to come here and visit more often. Did you hire out a designer
    to create your theme? Great work!

  36. I love your blog.. very nice colors & theme.
    Did you create this website yourself or did you hire someone to do it for you?
    Plz reply as I’m looking to design my own blog and
    would like to know where u got this from. cheers

  37. I appreciate, cause I found exactly what I used to be taking a look for. You have ended my four day long hunt! God Bless you man. Have a nice day. Bye

  38. That is very interesting, You are a very skilled blogger.

    I have joined your feed and stay up for looking for more of your wonderful post.
    Also, I have shared your site in my social networks

  39. Great beat ! I wish to apprentice while you amend your site, how could
    i subscribe for a blog web site? The account aided me a acceptable deal.
    I had been a little bit acquainted of this your broadcast provided bright clear concept

  40. Hey there! I could have sworn I’ve been to this site before
    but after reading through some of the post I realized it’s new to me.
    Nonetheless, I’m definitely delighted I found it and I’ll be book-marking and checking back frequently!

  41. I wwas curious іf yоu vеr ϲonsidered changing tһe structure of yоu site?
    ӏts very well ԝritten; Ⅰ love what youve goot tο
    say. But maybе you coᥙld a littlе morᥱ in the way of cοntent so people coulɗ connect
    աith it better. Youve gߋt an awful lot ⲟf text fⲟr
    only having 1 or twoo images. Maybe уoᥙ could space itt
    out better?

  42. Its such as you learn my mind! You appear to understand a lot approximately this,
    such as you wrote the e-book in it or something.
    I feel that you could do with a few % to drive the message house a bit, however instead of that, this is wonderful blog.
    A fantastic read. I will certainly be back.

  43. I think what you published made a lot of sense. But, think on this, suppose you added a little information? I ain’t
    saying your information is not good, but what
    if you added a title that grabbed people’s attention? I mean Opencv图像核心基本操作(4拆分及合并图像通道) – Opencv步步精深 is a little boring.

    You should peek at Yahoo’s front page and see how they create news titles to grab people interested.

    You might try adding a video or a related picture or two to grab
    readers excited about everything’ve got to say. Just my opinion, it might make your posts a
    little livelier.

  44. I do not know if it’s just me or if everyone else experiencing problems
    with your site. It appears as though some of the text within your content are running off the screen. Can somebody
    else please comment and let me know if this is happening to them as well?
    This could be a problem with my internet browser because I’ve had this happen previously.
    Appreciate it

  45. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make
    your point. You definitely know what youre talking about, why throw away your intelligence on just posting videos to your site when you could be giving us something enlightening to read?

  46. This is the right blog for everyone who wants to find out about this topic.

    You realize a whole lot its almost tough to argue with you (not that I personally will need to…HaHa).
    You certainly put a fresh spin on a topic that has been discussed
    for a long time. Excellent stuff, just wonderful!

  47. Great beat ! I wish to apprentice while you
    amend your website, how could i subscribe for a blog web site?
    The account aided me a acceptable deal. I had been a little bit acquainted of this your broadcast offered bright clear idea

  48. Thank you for some other informative site. The
    place else could I get that kind of information written in such a perfect manner?
    I’ve a challenge that I am simply now working on, and I have
    been on the look out for such information.

  49. Wow that was unusual. I just wrote an extremely long comment but after
    I clicked submit my comment didn’t appear. Grrrr… well I’m not writing all that over again. Anyways, just wanted to say
    wonderful blog!

  50. Nice read, I just passed this onto a colleague who
    was doing a little research on that. And he just bought me lunch since I found it for him smile Therefore let me rephrase that: Thanks for lunch!

  51. Hey very nice website!! Man .. Beautiful .. Amazing .. I’ll bookmark your website and take the feeds alsoI’m happy to find numerous useful information here in the post, we need work out more techniques in this regard, thanks for sharing

  52. Hello just wanted to give you a brief heads up and let you know a few of the
    images aren’t loading correctly. I’m not sure why but I think its a linking
    issue. I’ve tried it in two different browsers and both show the same outcome.

  53. Hello There. I found your blog using msn. That is a really well
    written article. I’ll make sure to bookmark it and return to learn extra of your helpful information. Thanks for the post.

    I’ll definitely return.

  54. I have read several good stuff here. Certainly worth bookmarking for revisiting. I surprise how much effort you put to make such a magnificent informative web site.

  55. Its like you read my mind! You seem to know so much about this, like you wrote the book in it or something. I think that you could do with a few pics to drive the message home a little bit, but other than that, this is great blog. An excellent read. I will certainly be back.

  56. Thank you, I have just been searching for information approximately this subject for ages and yours is the best I have came upon till now. But, what concerning the conclusion? Are you certain in regards to the supply?

  57. Amazing YouTube movies posted at this website, I am going to subscribe for daily updates, as I dont want to fail to take this series.

  58. Excellent blog you have here but I was wondering if you knew of
    any forums that cover the same topics talked about in this article?

    I’d really love to be a part of online community
    where I can get responses from other knowledgeable
    people that share the same interest. If you have any recommendations, please let me know.
    Thanks!

  59. hi!,I really like your writing so so much! proportion we communicate extra approximately your article on AOL?
    I require a specialist in this space to unravel my problem.
    May be that’s you! Looking ahead to see you.

  60. What i don’t realize is in reality how you are now not really much more neatly-favored than you might be now.

    You’re so intelligent. You recognize thus significantly in the
    case of this topic, produced me personally consider it from a lot of various angles.
    Its like women and men don’t seem to be fascinated except it is
    something to do with Girl gaga! Your personal stuffs great.
    All the time care for it up!

  61. Hey superb blog! Does running a blog like this require a great
    deal of work? I have no expertise in computer programming however I was hoping to
    start my own blog soon. Anyway, if you have any ideas or tips for new blog owners please share.
    I understand this is off topic however I just had to ask.
    Thanks a lot!

  62. I have been exploring for a bit for any high quality articles or blog posts on this kind of house .
    Exploring in Yahoo I finally stumbled upon this site.
    Reading this info So i am satisfied to express that I’ve an incredibly good
    uncanny feeling I found out just what I needed. I so
    much definitely will make certain to do not put out of your mind this site
    and provides it a look regularly.

  63. Awesome blog! Do you have any tips and hints
    for aspiring writers? I’m planning to start my own blog soon but I’m a little
    lost on everything. Would you advise starting with a free platform like
    Wordpress or go for a paid option? There are so many options out there that I’m totally overwhelmed ..
    Any tips? Appreciate it!

  64. Attractive section of content. I just stumbled upon your web site
    and in accession capital to claim that I acquire actually loved account
    your weblog posts. Any way I will be subscribing on your augment
    or even I fulfillment you access persistently quickly.

  65. Hey, you used to write fantastic, but the last few
    posts have been kinda boring? I miss your tremendous writings.
    Past few posts are just a little bit out of track!
    come on!

  66. Greate pieces. Keep posting suсһ kind of іnformation ߋn youг рage.

    ӏm rеally impressed bу it.
    Hi there, You’νе performed aan excellent job. Ι’ll definitelʏ digg it and individually sᥙggest toо my friends.
    ӏ am confident tɦey’ll be benefited frߋm thks site.

  67. Oh my goodness! Amazing article dude! Thanks, However
    I am experiencing difficulties with your RSS.

    I don’t know why I cannot join it. Is there anybody else getting identical RSS issues?

    Anybody who knows the answer will you kindly respond? Thanks!!

  68. This is really interesting, you’re a really professional blogger.
    I’ve joined your rss feed as well as sit up for trying
    to find more of your excellent post.Also, I have shared your site in my social networks!

  69. Hey there just wanted to give you a quick heads up.
    The text in your content seem to be running off the screen in Firefox.
    I’m not sure if this is a format issue or something to do with browser compatibility but I thought
    I’d post to let you know. The style and design look great though!
    Hope you get the problem fixed soon. Many thanks

  70. Great blog here! Also your site loads up fast!

    What host are you using? Can I get your affiliate link to your host?
    I wish my web site loaded up as quickly as yours lol

  71. Very nice info and right to the point. I am not sure if this is in fact the best
    place to ask but do you people have any ideea where to employ some professional writers?
    Thank you 🙂

  72. Today, I went to the beach with my children. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.”
    She put the shell to her ear and screamed. There
    was a hermit crab inside and it pinched her ear. She never
    wants to go back! LoL I know this is totally off topic but I had to tell someone!

  73. What yyou published made a greeat deal of sense. But,
    consider this, suppose you added a little information? I
    mean, I don’t wish to tell you how to run your blog, however
    suppose you added a post title to possibly gett people’s
    attention? I mean Opencv图像核心基本操作(4拆分及合并图像通道) – Opencv步步精深 is a little plain.
    You should look at Yahoo’s home page and see how they create nees titles to gget viewers too open the links.
    You might try adding a video or a picture orr two to grab readers excited about everything’ve got
    to say. In my opinion, it would make your posts a little
    bit more interesting.

  74. My coder is trying to persuade me to move to .net from PHP.
    I have always disliked the idea because of the costs.
    But he’s tryiong none the less. I’ve been using Movable-type on
    a variety of websites for about a year and am worried about switching to
    another platform. I have heard good things about blogengine.net.
    Is there a way I can import all my wordpress content into it?
    Any kind of help would be really appreciated!

  75. Its like you learn my thoughts! You appear to know so much approximately this, such as you wrote the e-book in it or something.
    I believe that you just can do with some % to force the message house
    a little bit, however other than that, this is wonderful
    blog. A fantastic read. I’ll definitely be back.

  76. Hello, I think your website might be having browser compatibility issues. When I look at your blog in Chrome, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, superb blog!

  77. This can be my own individual blog. I target exceptional show and getting to
    every product. I reveal educating, technologies,
    command, productivity, along with composing. At some time I contact stuff that don’t suit neatly in to those categories.

    My personal objective is usually to assist numerous kids as possible
    with helping their own instructors absorb them, attain them, then be the class room a great incredible place
    to hear.

  78. Having read this I believed it was really informative.
    I appreciate you spending some time and energy to put this informative article together.
    I once again find myself personally spending a significant amount of time both reading and posting comments.
    But so what, it was still worth it!

  79. I just like the helpful info you provide to your articles. I will bookmark your weblog and check once more here frequently. I am reasonably certain I’ll learn plenty of new stuff proper here! Good luck for the next!

  80. HiHelloHi thereWhat’s up, I log on tocheckread your new stuffblogsblog regularlylike every weekdailyon a regular basis. Your story-tellingwritinghumoristic style is awesomewitty, keep doing what you’re doingup the good workit up!

  81. Excellent website you have here but I was curious about if you knew of any discussion boards that cover the same topics
    talked about here? I’d really love to be a part of
    community where I can get advice from other knowledgeable individuals that share the same interest.
    If you have any suggestions, please let me know. Thank you!

  82. Howdy! Someone in my Facebook group shared this site with us so I came to check it out.
    I’m definitely loving the information. I’m book-marking and will
    be tweeting this to my followers! Outstanding blog and superb
    style and design.

发表评论

电子邮件地址不会被公开。 必填项已用*标注