Question: On a website which currently is serving on `HTTPS`, I want to redirect some pages to `HTTP` and not use `SSL` on them. In nginx I configured it like this:

```
server{
  listen 80;
  server_name example.com;
  location / {
      root /var/some/where;
  }

  location /secure {
      return 301 https://example.com$request_uri;
  }
}

server{
  listen 443 ssl;
  server_name example.com;
  include ssl_params;
  location /secure {
      root /var/some/where/secure;
  }

  location / {
      return 301 http://example.com$request_uri;
  }
}

```

Using `curl` I can see everything is fine as follow:

```
$ curl -sIL https://example.com/ | grep HTTP
HTTP/1.1 301 Moved Permanently
HTTP/1.1 200 OK

$ curl -sIL http://example.com/ | grep HTTP
HTTP/1.1 200 OK

```

But when I try to open `HTTPS` url in `Firefox`, I'll get this error:

```
The page isn't redirecting properly. 
Firefox has detected that the server is redirecting the request for this address in a way that will never complete. 
This problem can sometimes be caused by disabling or refusing to accept cookies

```

Using a private window, when I try to open url in `HTTP` for the first time, is OK. But as soon as I refresh the page, It'll be redirected to `HTTPS` scheme and the error will appear again.

Answer: 
There is numpy's builtin indexing which can be used for replacing elements. This is can be done as:

```
Image[Image<0.5] = 0

```
I have returned from the future with suggestions.

The above approaches work great for a simple global threshold. 
I'm posting this answer to warn that non-adaptive thresholding, like this, may be too naïve depending on your application.

Without adaptation to an image's average brightness or other qualities, your output won't be consistent if you are analyzing multiple pictures taken in different conditions.

There are much more accurate approaches for this, but they are a tiny bit more complicated. Scikit-Image makes this easy.

One of the most popular approaches is Otsu's (I can't say which is the most accurate for each situation, I haven't researched enough).
<https://en.wikipedia.org/wiki/Otsu%27s_method>

Scikit-Image has this and a few other algorithms built into their modules.

The answer to the question above, using this approach, is as simple as this:

```
import matplotlib.pyplot as plt
from skimage.filters import threshold_otsu

thresh = threshold_otsu(Image)
binary = Image > thresh

plt.imshow(Image, cmap=plt.cm.gray)
plt.show()

```

Read an example here:
<http://scikit-image.org/docs/dev/auto_examples/plot_otsu.html>

And about usage here:
<http://scikit-image.org/docs/dev/api/skimage.filters.html?highlight=local%20otsu>