who is the better method to take images from uses(visitors)on the fly on my web site and to return the new images(with some processing) back to users using DJANGO?
i am new i dont know how to connect my python script with the html templates to take the images and how to return.
for example my script take images paths to processing new images with new paths. a simple image classification with GDAL :
# Input file name (thermal image)
src = "thermal.tif"
# Output file name
tgt = "classified.jpg"
# Load the image into numpy using gdal
srcArr = gdalnumeric.LoadFile(src)
# Split the histogram into 20 bins as our classes
classes = gdalnumeric.numpy.histogram(srcArr, bins=20)[1]
# Color look-up table (LUT) - must be len(classes)+1.
# Specified as R,G,B tuples
lut = [[255,0,0],[191,48,48],[166,0,0],[255,64,64],
[255,115,115],[255,116,0],[191,113,48],[255,178,115],
[0,153,153],[29,115,115],[0,99,99],[166,75,0],
[0,204,0],[51,204,204],[255,150,64],[92,204,204],[38,153,38],
\ [0,133,0],[57,230,57],[103,230,103],[184,138,0]]
# Starting value for classification
start = 1
# Set up the RGB color JPEG output image
rgb = gdalnumeric.numpy.zeros((3, srcArr.shape[0],
srcArr.shape[1],), gdalnumeric.numpy.float32)
# Process all classes and assign colors
for i in range(len(classes)):
mask = gdalnumeric.numpy.logical_and(start <= \
srcArr, srcArr <= classes[i])
for j in range(len(lut[i])):
rgb[j] = gdalnumeric.numpy.choose(mask, (rgb[j], \ lut[i][j]))
start = classes[i]+1
# Save the image
gdalnumeric.SaveArray(rgb.astype(gdalnumeric.numpy.uint8), \
tgt, format="JPEG")
This script takes image input src a take new image with classification. but i dont know how to programming the post,get and image output from the python script in html form template .
i know to change python script in Django to can run i html template maybe for the input like this variable = request.POST.get('variable', False) and the output image like this return render_to_response ('blog/calc.html', {'variable' :variable,
but i dont have experience with this and i dont know if this method is better or no.
can i have django form without files upload to save samoe path ?
On Thursday 02 February 2017 08:09:20 Xristos Xristoou wrote:
> who is the better method to take images from uses(visitors)on the fly
> on my web site and to return the new images(with some processing)
> back to users using DJANGO?
Start here:
Looking at your code you may also be interested in the GIS module.
--
Melvyn Sopacua