Giter Site home page Giter Site logo

internship_at_iitk's People

Contributors

sid-kumar-iyer avatar

internship_at_iitk's Issues

Sanity of input coordinates for area interpolation

When interpolating the pixel intensity based on area, your code does not check for the sanity of input. You may either:

  1. Sanitize your code, or
  2. replace it with:
import numpy as np
import math

def spatial_interpolation(image, p) :
  ## sanity check
  if (np.any(np.array(p) < 0) or
      np.any(np.array(p[::-1]) >= image.shape)) :
    raise IndexError('%s: [LB: 0 UB): %s', p[::-1], image.shape)

  x, y = p
  dx, dy = p - np.floor(p)

  # lg.debug((x, y, dx, dy))

  I = np.array([[
    image[int(math.floor(y)), int(math.floor(x))],
    image[int(math.floor(y)), int(math.floor(1 + x))]
  ],[
    image[int(math.floor(1 + y)), int(math.floor(x))],
    image[int(math.floor(1 + y)), int(math.floor(1 + x))]
  ]])

  A = np.matmul(
    np.array([[1 - dy, dy]]).T,
    np.array([[1 - dx, dx]])
  )

  value = np.sum(I * A)

  # lg.debug((I, A, value))

  return value

This piece of code raises exception... The caller is responsible to handle the exception

Limit of 1000 on number of lines or something like that...

vis1=np.full((1000,),1)

vis=np.full((1000,),1)

Instead of hardcoding the memory allocation, you may:

  1. wait for the limit to be known before you initialize the array,
  2. try-catch to update the limit when the program crosses the limit.
  3. Heuristically, set a larger memory --- strongly suggested against, because, it limits the capacity of parallel of the processing

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.