<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lucas de Brito Silva</title>
    <description>The latest articles on DEV Community by Lucas de Brito Silva (@lucs1590).</description>
    <link>https://dev.to/lucs1590</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F360717%2F0bf6eede-ae2c-42ee-81fd-d740b94acdf9.png</url>
      <title>DEV Community: Lucas de Brito Silva</title>
      <link>https://dev.to/lucs1590</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lucs1590"/>
    <language>en</language>
    <item>
      <title>Answer: How do I increase the contrast of an image in Python OpenCV</title>
      <dc:creator>Lucas de Brito Silva</dc:creator>
      <pubDate>Tue, 21 Jul 2020 14:40:53 +0000</pubDate>
      <link>https://dev.to/lucs1590/answer-how-do-i-increase-the-contrast-of-an-image-in-python-opencv-2mn2</link>
      <guid>https://dev.to/lucs1590/answer-how-do-i-increase-the-contrast-of-an-image-in-python-opencv-2mn2</guid>
      <description>&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;div class="ltag__stackexchange--header"&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AoTUKOcU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/stackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
          &lt;a href="https://stackoverflow.com/questions/39308030/how-do-i-increase-the-contrast-of-an-image-in-python-opencv/50053219#50053219" rel="noopener noreferrer"&gt;
            &lt;span class="title-flare"&gt;answer&lt;/span&gt; re: How do I increase the contrast of an image in Python OpenCV
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Apr 26 '18&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/39308030/how-do-i-increase-the-contrast-of-an-image-in-python-opencv/50053219#50053219" rel="noopener noreferrer"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oeieW07A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/stackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          74
        &lt;/div&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h2-sXgSn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/stackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;For Python, I haven't found an OpenCV function that provides contrast. As others have suggested, there are some techniques to automatically increase contrast using a very simple  formula.&lt;/p&gt;
&lt;p&gt;In the &lt;a href="https://docs.opencv.org/master/d3/dc1/tutorial_basic_linear_transform.html" rel="noreferrer"&gt;official OpenCV docs&lt;/a&gt;, it is suggested that this equation can be used to apply both contrast and brightness at…&lt;/p&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    &lt;a href="https://stackoverflow.com/questions/39308030/how-do-i-increase-the-contrast-of-an-image-in-python-opencv/50053219#50053219" class="ltag__stackexchange--btn" rel="noopener noreferrer"&gt;Open Full Answer&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Module, Package, Library or Framework?</title>
      <dc:creator>Lucas de Brito Silva</dc:creator>
      <pubDate>Fri, 19 Jun 2020 11:34:00 +0000</pubDate>
      <link>https://dev.to/lucs1590/python-module-vs-package-vs-library-vs-framework-4i0p</link>
      <guid>https://dev.to/lucs1590/python-module-vs-package-vs-library-vs-framework-4i0p</guid>
      <description>&lt;p&gt;&lt;strong&gt;Module&lt;/strong&gt; is a file which contains various Python functions and global variables. It is simply just .py extension file which has python executable code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Package&lt;/strong&gt; is a collection of modules. It must contain an __init__.py file as a flag so that the python interpreter processes it as such. The __init__.py could be an empty file without causing issues.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Library&lt;/strong&gt; is a collection of packages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Framework&lt;/strong&gt; is a collection of libraries. This is the architecture of the program.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Application&lt;/strong&gt; is an application. Yah, I’m sure about this one.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reference
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kimconnect.com/python-module-vs-package-vs-library-vs-framework/"&gt;https://kimconnect.com/python-module-vs-package-vs-library-vs-framework/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>architecture</category>
      <category>beginners</category>
      <category>todayilearned</category>
    </item>
    <item>
      <title>TRICK: Easy requirements build</title>
      <dc:creator>Lucas de Brito Silva</dc:creator>
      <pubDate>Mon, 25 May 2020 03:52:00 +0000</pubDate>
      <link>https://dev.to/lucs1590/trick-easy-requirements-build-k1h</link>
      <guid>https://dev.to/lucs1590/trick-easy-requirements-build-k1h</guid>
      <description>&lt;p&gt;A few days ago I was doing a project in Python and wanted to let it practice for anyone who wanted to access it, and one of the steps for that was to build the requirements.txt, that commonly loads the necessary packages to run the projects in Python and the easiest alternative is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;view the packages in the project;&lt;/li&gt;
&lt;li&gt;select the packages after executing:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;pip freeze
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;But that's not practical at all, so I looked for an alternative that would meet my need, and found a project that did just that. Its goal is generate requirements.txt based on imports in project.&lt;/p&gt;



&lt;p&gt;To install this package, just run:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;pipreqs &lt;span class="nt"&gt;--user&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;or, if you use Python3:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;pip3 &lt;span class="nb"&gt;install &lt;/span&gt;pipreqs &lt;span class="nt"&gt;--user&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;To build automatically your requirements.txt, just run the following command in the project directory:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;pipreqs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;pipreqs /project/location
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And the magic will happen!!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fma3ana2a15bjb3ymz7a3.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fma3ana2a15bjb3ymz7a3.jpg" alt="Magic" width="800" height="535"&gt;&lt;/a&gt;&lt;br&gt;
I hope this post helped and feel free to get in touch! ;)&lt;br&gt;
Thanks for reading!&lt;/p&gt;



&lt;p&gt;This post is inspired by the following repository:&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A9-wwsHG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/bndr"&gt;
        bndr
      &lt;/a&gt; / &lt;a href="https://github.com/bndr/pipreqs"&gt;
        pipreqs
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      pipreqs - Generate pip requirements.txt file based on imports of any project. Looking for maintainers to move this project forward.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="rst"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 id="user-content-pipreqs---generate-requirements.txt-file-for-any-project-based-on-imports" class="heading-element"&gt;
&lt;code&gt;pipreqs&lt;/code&gt; - Generate requirements.txt file for any project based on imports&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href="https://travis-ci.org/bndr/pipreqs" rel="nofollow"&gt;&lt;img src="https://camo.githubusercontent.com/f4a65696c9eed17a87f42ef2e68277bc7750c7eb192701823bc99f68fd696226/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f626e64722f706970726571732e737667" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pypi.python.org/pypi/pipreqs" rel="nofollow"&gt;&lt;img src="https://camo.githubusercontent.com/243c66da5f5b9f50a2dad243f25d89b69e5d1c8cbc16f5612d5a420defd24d80/68747470733a2f2f696d672e736869656c64732e696f2f707970692f762f706970726571732e737667" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codecov.io/gh/bndr/pipreqs" rel="nofollow"&gt;&lt;img src="https://camo.githubusercontent.com/3a5164e7b71e42fd0cefb260e9119633964ebfda5d8fa44909153e569249d25f/68747470733a2f2f636f6465636f762e696f2f67682f626e64722f706970726571732f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d3072665066555a454158" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pypi.python.org/pypi/pipreqs" rel="nofollow"&gt;&lt;img src="https://camo.githubusercontent.com/17239bf82fb5d6e00d082be35de06482554229e4ea41c92018db1f4d6456a827/68747470733a2f2f696d672e736869656c64732e696f2f707970692f6c2f706970726571732e737667" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 id="user-content-installation" class="heading-element"&gt;Installation&lt;/h2&gt;
&lt;/div&gt;

&lt;div id="user-content-cb1"&gt;&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;&lt;a id="user-content-cb1-1" title="1" href="https://github.com/bndr/pipreqs"&gt;&lt;span&gt;pip&lt;/span&gt; install pipreqs&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Obs.: if you don't want support for jupyter notebooks, you can install pipreqs without the dependencies that give support to it. To do so, run:&lt;/p&gt;

&lt;div id="user-content-cb2"&gt;&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;&lt;a id="user-content-cb2-1" title="1" href="https://github.com/bndr/pipreqs"&gt;&lt;span&gt;pip&lt;/span&gt; install --no-deps pipreqs&lt;/a&gt;
&lt;a id="user-content-cb2-2" title="2" href="https://github.com/bndr/pipreqs"&gt;&lt;span&gt;pip&lt;/span&gt; install yarg==0.1.9 docopt==0.6.2&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 id="user-content-usage" class="heading-element"&gt;Usage&lt;/h2&gt;
&lt;/div&gt;

&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;
&lt;pre class="notranslate"&gt;&lt;code&gt;Usage
    pipreqs [options] [&amp;lt;path&amp;gt;]

Arguments:
    &amp;lt;path&amp;gt;                The path to the directory containing the application files for which a requirements file
                          should be generated (defaults to the current working directory)

Options:
    --use-local           Use ONLY local package info instead of querying PyPI
    --pypi-server &amp;lt;url&amp;gt;   Use custom PyPi server
    --proxy &amp;lt;url&amp;gt;         Use Proxy, parameter will be passed to requests library. You can also just set the
                          environments parameter in your terminal:
                          $ export HTTP_PROXY="http://10.10.1.10:3128"
                          $ export HTTPS_PROXY="https://10.10.1.10:1080"
    --debug               Print debug information
    --ignore &amp;lt;dirs&amp;gt;...    Ignore extra directories, each separated by a comma
    --no-follow-links     Do not follow symbolic links in the project
    --encoding &amp;lt;charset&amp;gt;  Use encoding&lt;/code&gt;&lt;/pre&gt;…&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/bndr/pipreqs"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;



</description>
      <category>python</category>
      <category>pip</category>
      <category>help</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Answer: matplotlib: binary heat plot</title>
      <dc:creator>Lucas de Brito Silva</dc:creator>
      <pubDate>Mon, 18 May 2020 11:33:12 +0000</pubDate>
      <link>https://dev.to/lucs1590/answer-matplotlib-binary-heat-plot-4kn</link>
      <guid>https://dev.to/lucs1590/answer-matplotlib-binary-heat-plot-4kn</guid>
      <description>&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;div class="ltag__stackexchange--header"&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AoTUKOcU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/stackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
          &lt;a href="https://stackoverflow.com/questions/28517400/matplotlib-binary-heat-plot/28518631#28518631" rel="noopener noreferrer"&gt;
            &lt;span class="title-flare"&gt;answer&lt;/span&gt; re: matplotlib: binary heat plot
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Feb 14 '15&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/28517400/matplotlib-binary-heat-plot/28518631#28518631" rel="noopener noreferrer"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oeieW07A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/stackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          9
        &lt;/div&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h2-sXgSn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/stackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;You need what's known as a &lt;code&gt;ListedColorMap&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl

# random data
x = np.random.random_integers(0, 1, (10, 10))

fig, ax = plt.subplots()

# define the colors
cmap = mpl.colors.ListedColormap(['r', 'k'])

# create a normalize object the describes the limits&lt;/code&gt;&lt;/pre&gt;…
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    &lt;a href="https://stackoverflow.com/questions/28517400/matplotlib-binary-heat-plot/28518631#28518631" class="ltag__stackexchange--btn" rel="noopener noreferrer"&gt;Open Full Answer&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Rename and Delete files with Python</title>
      <dc:creator>Lucas de Brito Silva</dc:creator>
      <pubDate>Sat, 25 Apr 2020 19:47:31 +0000</pubDate>
      <link>https://dev.to/lucs1590/rename-and-delete-files-with-python-2le4</link>
      <guid>https://dev.to/lucs1590/rename-and-delete-files-with-python-2le4</guid>
      <description>&lt;p&gt;Every day I find myself in need of doing tiring jobs that can be replaced by scripts and that the computer can help me too much, so one day I thought "Okay, I got tired, from now on I refuse to do that kind of work!" and from then on things only got better.&lt;/p&gt;

&lt;p&gt;Since college, I created a great bond with the Python programming language, and we became great friends. That way I developed a script with him that would save my life!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0z1ynzex9rutgp8r148w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0z1ynzex9rutgp8r148w.png" alt="Alt Text" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In my work sometimes I needed to rename files from a list or even delete them from a folder, because they were no longer useful. So my first approach was to create two functions.&lt;/p&gt;

&lt;p&gt;The first function was to rename files, so that they had a pattern and an order, like: file_1, file_2 and so on.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The heart of this code, as you can see, is in the &lt;strong&gt;os.rename&lt;/strong&gt; that renames from the old name to the new file name.&lt;br&gt;
&lt;strong&gt;NOTE: One very cool thing is that the script renames the whole way, so it makes use of the glob.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The second problem was that I needed to delete all files that were not on a .txt list (believe me, that list was over 100 files). So I used a very similar approach, but with the use of &lt;strong&gt;pandas&lt;/strong&gt;, to read the txt file, of &lt;strong&gt;.index&lt;/strong&gt; to try to find the file and &lt;strong&gt;os.remove&lt;/strong&gt; to remove the files outside the list. The code is shown below.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;And it's because of scripts like these that I have time today to write this article for you. I hope you like it and that it helped!&lt;/p&gt;

</description>
      <category>python</category>
      <category>linux</category>
      <category>productivity</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
