精选图像处理100题-python&c++版本

图像处理100题介绍

图像处理经常会使用opencv及其实现的各种算法, 如仿射变换、滤波等.
最近一直苦恼怎么再学习下opencv、opengl等, 浏览知乎的时候发现了这个图像处理100问,发现完成度还是蛮高的,所以就先mark下,留待后续联系用

这份资源教程是用日语写的,读起来非常不方便。不过好人guozirui帮忙把这份教程翻译成了中文版。该项目包含了 CV 领域,OpenCV 图像处理入门 100 题实例解析,并配备完整的 Pyhon 代码。

端上fork的github地址
https://github.com/kiah2008/ImageProcessing100Wen

内容 Python C++ JavaScript
1 安装
2 读取、显示图像
3 操作像素
4 拷贝图像
5 保存图像
6 练习问题

放上原版日文地址:

https://github.com/yoyoyo-yo/Gasyori100knock

对应的中文版翻译地址:

https://github.com/gzr2017/ImageProcessing100Wen

100题练习

后续会登录100题的解题过程, 欢迎后续关注

问题1-通道交换

读取图像,然后将RGB通道替换成BGR通道。

下面的代码用于提取图像的红色通道。

注意,cv2.imread() 的系数是按BGR顺序排列的!

其中的变量red表示的是仅有原图像红通道的imori.jpg。

import cv2
img = cv2.imread("imori.jpg")
red = img[:, :, 2].copy()
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>

// Channel swap
cv::Mat channel_swap(cv::Mat img){
  // get height and width
  int width = img.cols;
  int height = img.rows;

  // prepare output
  cv::Mat out = cv::Mat::zeros(height, width, CV_8UC3);

  // each y, x
  for (int y = 0; y < height; y++){
    for (int x = 0; x < width; x++){
      // R -> B
      out.at<cv::Vec3b>(y, x)[0] = img.at<cv::Vec3b>(y, x)[2];
      // B -> R
      out.at<cv::Vec3b>(y, x)[2] = img.at<cv::Vec3b>(y, x)[0];
      // G -> G
      out.at<cv::Vec3b>(y, x)[1] = img.at<cv::Vec3b>(y, x)[1];
    }
  }

  return out;
}

int main(int argc, const char* argv[]){
  // read image
  cv::Mat img = cv::imread("imori.jpg", cv::IMREAD_COLOR);

  // channel swap
  cv::Mat out = channel_swap(img);

  //cv::imwrite("out.jpg", out);
  cv::imshow("sample", out);
  cv::waitKey(0);
  cv::destroyAllWindows();

  return 0;
}
内容 结果

参考资料

知乎图像处理

标签:, ,

About: kiah


45 thoughts on “精选图像处理100题-python&c++版本”

  1. I wanted to put you the tiny remark to be able to thank you over again on your precious suggestions you have provided on this page. It was really strangely open-handed with you to make unhampered precisely what many people would’ve offered for sale for an ebook to get some money for themselves, particularly now that you might have tried it in case you desired. These solutions in addition served to be the good way to know that some people have the identical interest really like my personal own to learn much more when considering this matter. I believe there are several more pleasant sessions in the future for many who read through your site.

  2. I intended to compose you a bit of note in order to give many thanks again considering the awesome basics you’ve contributed above. It’s generous of people like you giving easily all a few individuals could have advertised as an e-book in making some bucks for their own end, and in particular considering that you could have done it if you considered necessary. The basics additionally acted as a easy way to be aware that many people have a similar desire just as mine to figure out a great deal more concerning this condition. Certainly there are a lot more enjoyable instances ahead for folks who check out your blog.

  3. Thank you for every one of your hard work on this web page. My aunt really loves making time for investigations and it’s really obvious why. Most of us learn all of the lively mode you offer priceless tactics through this web site and even increase participation from some other people on the matter so our favorite girl is now starting to learn a lot of things. Take advantage of the rest of the year. You are always doing a remarkable job.

  4. I enjoy you because of all of your effort on this blog. Debby delights in conducting internet research and it’s easy to see why. A number of us hear all about the compelling manner you create effective guides by means of the blog and boost contribution from other ones about this area of interest and my child has been becoming educated a great deal. Enjoy the remaining portion of the new year. You’re carrying out a fabulous job.

  5. I’m just commenting to let you be aware of of the exceptional discovery my cousin’s daughter enjoyed going through your blog. She discovered lots of issues, most notably how it is like to have a very effective giving heart to have many more effortlessly fully understand certain extremely tough matters. You really did more than my desires. Many thanks for displaying the helpful, healthy, educational and also easy thoughts on the topic to Gloria.

  6. I’m commenting to let you be aware of of the amazing discovery my child developed browsing the blog. She came to find a good number of details, including how it is like to have a great coaching character to get a number of people clearly completely grasp a number of advanced issues. You actually did more than her desires. I appreciate you for churning out such beneficial, dependable, edifying and cool guidance on that topic to Emily.

  7. I’m also commenting to let you be aware of of the cool discovery my child encountered checking your blog. She came to understand a lot of details, including how it is like to have a marvelous coaching heart to get folks easily fully grasp a variety of complicated issues. You actually did more than my desires. I appreciate you for delivering such good, dependable, edifying and also cool guidance on that topic to Ethel.

  8. I enjoy you because of all of your effort on this blog. Ellie enjoys doing internet research and it’s easy to see why. All of us hear all about the compelling manner you create functional ideas by means of the blog and as well cause contribution from other ones about this article and my child is being taught a great deal. Enjoy the remaining portion of the new year. You’re the one carrying out a first class job.

  9. I precisely needed to appreciate you once again. I am not sure the things that I might have handled in the absence of the entire points provided by you on such a problem. It has been a very frightening dilemma in my circumstances, however , looking at the skilled mode you processed that made me to jump over fulfillment. I am happier for this help and in addition hope that you know what a great job you are always getting into instructing others through the use of your web blog. I know that you have never encountered all of us.

  10. My spouse and i got quite joyful that Jordan managed to do his reports through the entire precious recommendations he had through the web pages. It is now and again perplexing to just continually be handing out secrets which people may have been selling. So we keep in mind we have got the writer to give thanks to for that. The most important illustrations you have made, the simple web site navigation, the relationships you will help foster – it’s got many incredible, and it’s really helping our son in addition to the family know that the situation is exciting, which is rather mandatory. Thank you for everything!

  11. My husband and i felt absolutely ecstatic Edward could complete his homework from the ideas he discovered from your very own site. It’s not at all simplistic just to be giving for free helpful tips that men and women could have been making money from. And we do know we have the blog owner to appreciate because of that. Most of the explanations you’ve made, the easy blog menu, the friendships you assist to engender – it’s everything excellent, and it’s assisting our son and our family do think that content is brilliant, and that’s extremely fundamental. Many thanks for all the pieces!

  12. I enjoy you because of all of the effort on this blog. Betty delights in carrying out internet research and it’s easy to see why. A lot of people hear all about the compelling form you convey advantageous guidance by means of the blog and attract contribution from other individuals about this area and my child has always been becoming educated a great deal. Enjoy the remaining portion of the new year. You’re carrying out a brilliant job.

  13. I simply had to appreciate you all over again. I’m not certain the things I might have followed in the absence of the actual information documented by you directly on such field. It became a real distressing crisis for me personally, but encountering a new professional form you managed it forced me to jump for delight. I’m just happier for the guidance and even have high hopes you find out what a powerful job you’re doing instructing most people through your blog post. I am sure you’ve never encountered all of us.

  14. A lot of thanks for each of your hard work on this web page. Kim really likes going through investigation and it’s really easy to understand why. Many of us know all of the dynamic method you make powerful steps on this web blog and as well as improve participation from people on that issue so our girl is in fact learning a lot of things. Have fun with the remaining portion of the new year. You are conducting a pretty cool job.

  15. Thanks for your concepts. One thing we’ve noticed is banks along with financial institutions are aware of the spending practices of consumers while also understand that most of the people max out and about their real credit cards around the getaways. They properly take advantage of this specific fact and commence flooding your current inbox along with snail-mail box using hundreds of no-interest APR card offers just after the holiday season concludes. Knowing that should you be like 98% of American community, you’ll rush at the possible opportunity to consolidate card debt and shift balances for 0 apr interest rates credit cards. kjjiikm https://headachemedi.com – guided meditation for headache relief

  16. Thanks for your tips. One thing we have noticed is always that banks and also financial institutions have in mind the spending behavior of consumers and also understand that a lot of people max out there their own credit cards around the holiday seasons. They prudently take advantage of this kind of fact and begin flooding the inbox and also snail-mail box together with hundreds of Zero APR card offers immediately after the holiday season comes to an end. Knowing that in case you are like 98% of all American open public, you’ll hop at the possiblity to consolidate personal credit card debt and move balances for 0 interest rates credit cards. hgggfik https://headachemedi.com – drugs used for Headache problems

  17. Thanks for your concepts. One thing we’ve noticed is banks along with financial institutions are aware of the spending practices of consumers while also understand that most of the people max out and about their real credit cards around the getaways. They properly take advantage of this specific fact and commence flooding your current inbox along with snail-mail box using hundreds of no-interest APR card offers just after the holiday season concludes. Knowing that should you be like 98% of American community, you’ll rush at the possible opportunity to consolidate card debt and shift balances for 0 apr interest rates credit cards. kjjjilm https://headachemedi.com – meditation for headache relief

  18. Thanks for your thoughts. One thing I’ve got noticed is the fact banks in addition to financial institutions understand the spending behaviors of consumers and as well understand that the majority of people max out and about their real credit cards around the breaks. They smartly take advantage of that fact and commence flooding ones inbox in addition to snail-mail box having hundreds of no-interest APR credit cards offers shortly after the holiday season concludes. Knowing that for anyone who is like 98% of American community, you’ll soar at the possible opportunity to consolidate consumer credit card debt and shift balances towards 0 interest rate credit cards. lkkjjln https://thyroidmedi.com – how to treat hypothyroidism

  19. Thanks for your concepts. One thing we’ve noticed is banks along with financial institutions are aware of the spending practices of consumers while also understand that most of the people max out there their real credit cards around the getaways. They properly take advantage of this specific fact and commence flooding your current inbox along with snail-mail box using hundreds of no-interest APR card offers just after the holiday season comes to an end. Knowing that should you be like 98% of American community, you’ll rush at the possiblity to consolidate card debt and shift balances for 0 apr interest rates credit cards. jiiihkm https://thyroidmedi.com – over counter medicine for thyroid pain

  20. Thanks for your suggestions. One thing I’ve noticed is the fact that banks as well as financial institutions really know the spending routines of consumers as well as understand that many people max away their credit cards around the vacations. They sensibly take advantage of this particular fact and start flooding your own inbox as well as snail-mail box along with hundreds of 0 APR credit card offers right after the holiday season finishes. Knowing that if you’re like 98% of the American public, you’ll leap at the opportunity to consolidate credit debt and transfer balances to 0 annual percentage rates credit cards. ddddcfi https://stomachmedi.com – buy stomach medication

  21. Thanks for your strategies. One thing really noticed is that often banks plus financial institutions know the dimensions and spending patterns of consumers plus understand that many people max away their credit cards around the vacations. They sensibly take advantage of this particular fact and start flooding your own inbox as well as snail-mail box along with hundreds of 0 APR credit card offers right after the holiday season finishes. Knowing that if you’re like 98% of the American public, you’ll leap at the opportunity to consolidate credit debt and transfer balances to 0 annual percentage rates credit cards. dddccei https://stomachmedi.com – buy stomach medication

  22. Thanks for your ideas. One thing I have noticed is that banks and financial institutions know the spending habits of consumers and understand that most people max out their credit cards around the holidays. They wisely take advantage of this fact and start flooding your inbox and snail-mail box with hundreds of 0 APR credit card offers soon after the holiday season ends. Knowing that if you are like 98% of the American public, you’ll jump at the chance to consolidate credit card debt and transfer balances to 0 APR credit cards. aaaaaaa https://pancreasmedi.com – stomach pain drugs

  23. Thanks for your suggestions. One thing I’ve noticed is the fact that banks as well as financial institutions really know the spending routines of consumers as well as understand that many people max away their own credit cards around the vacations. They sensibly take advantage of this particular fact and begin flooding your own inbox as well as snail-mail box along with hundreds of Zero APR credit card offers right after the holiday season finishes. Knowing that if you’re like 98% of all American open public, you’ll leap at the opportunity to consolidate credit debt and move balances to 0 annual percentage rates credit cards. feeeegj https://pancreasmedi.com – stomach drugs for sale

发表评论

电子邮件地址不会被公开。