Giter VIP home page Giter VIP logo

mortcanty / crc4docker Goto Github PK

View Code? Open in Web Editor NEW
105.0 12.0 47.0 999.49 MB

Python scripts for the textbook "Image Analysis, Classification and Change Detection in Remote Sensing, Fourth Revised Edition"

License: MIT License

HTML 10.58% Jupyter Notebook 71.79% Shell 0.04% Python 12.93% Makefile 0.04% C 2.66% C++ 1.94% Dockerfile 0.02%
remote-sensing python image-analysis change-detection earth-engine classification-algorithm

crc4docker's Introduction

CRC4Docker

Source files for the Docker image mort/crc4docker

Python scripts for the textbook "Image Analysis, Classification and Change Detection in Remote Sensing, Fourth Revised Edition"

On Ubuntu, for example, pull and/or run the container for the first time with

sudo docker run -d -p 443:8888 -p 6006:6006 -v <my_image_folder>:/home/myimagery/ --name=crc4 mort/crc4docker

This maps the host directory my_image_folder to the container directory /home/myimagery/ and runs the container in detached mode.

Point your browser to http://localhost:443 to see the Jupyter home page and open a notebook.

In order to use Earth Engine scripts, you must authenticate. From the home page open a local terminal and enter

earthengine authenticate

and follow the instructions. This adds authentication information to the container and only has to be done once.

Stop the container with

sudo docker stop crc4  

Re-start with

sudo docker start crc4     

crc4docker's People

Contributors

mortcanty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crc4docker's Issues

Ensure sum of positive correlations between X and U is positive

Hi @mortcanty,

I had two questions regarding this section.

  1. The comment states that the aim of this section is to ensure sum of positive correlations between X and U is positive. What exactly is the purpose of this step and what is X in this case? From the book it is understood that U is the new multispectral image generated from the eigenvalue problem but it's unclear what X is.
  2. This step appears to be missing in the iMad_tf.py script. Is there a reason for this or did I miss something?

Thanks

Questions about geneiv function

Hi @mortcanty

I had 2 questions about the geneiv function.

  1. Is there a particular reason you went the Cholesky decomposition route?

I understand that numpy's eig function doesn't directly solve the generalised eigenproblem (Ax = λBx) as it doesn't accept a B parameter. But scipy's eig function does.

Comparing the two implementations below, you get the same eigenvalues and (scaled) eigenvectors so they are equivalent.

import scipy as sp
import numpy as np

def geneivprob(A,B):
    # Using scipy
    lamda, eigvec = sp.linalg.eig(A, B)
    return lamda, eigvec

def geneivprob2(A,B):
    """
    CRC4 method
    Reduce the problem to a standard symmetric eigenvalue problem
    Ax = λBx -> Cy = λy    
    """
    Linv = np.linalg.inv(np.linalg.cholesky(B))
    C = Linv @ A @ Linv.transpose()
    #C = np.asmatrix((C + C.transpose())*0.5,np.float32)
    lamda,V = np.linalg.eig(C)
    return lamda, Linv.transpose() @ V   

So did you go the Cholesky decomposition route becuase:

  • It was more efficient
  • To solve the problem in pure numpy
  1. What was the purpose of this line C = np.asmatrix((C + C.transpose())*0.5,np.float32)?

About linear stretching

Hi @mortcanty,

Is this lin2pcstr function doing the 2% linear stretch and histogram equalisation?

I ask because a standard linear stretch could be done as follows:

import numpy as np

def stretch(x, lower, upper, maxout=255, minout=0):
    a = (maxout - minout) / (upper - lower)
    b = minout - a * lower
    scaled = (a * x + b)
    scaled = np.clip(scaled, minout, maxout)
    return scaled

# Standard Linear stretch
lower = img.min()
upper = img.max()
scaled = stretch(img, lower, upper)

# 2% Linear stretch
lower = np.nanpercentile(img,2)
upper = np.nanpercentile(img, 98)
scaled2 = stretch(img, lower, upper)
                

Just wanted to be sure if I'm understanding the steps correctly.

Edit: I notice you already have bytestr() for stretching to the full byte range (0 to 255). So shouldn't the 2% stretch simply be bytestr(x, rng=[np.nanpercentile(img,2), np.nanpercentile(img,98)])?

Can't authenticate earth engine.

Hi~
Thanks for your book!
I want to do some exercise by using your docker config.
But when I try to authenticate earth engine, there is always a error that: urllib2.URLError: <urlopen error [Errno 99] Cannot assign requested address> after I entered authorization code.
I don't know hot to fix it, maybe I should config my docker?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.