Am currently accessing a s3 bucket from my school system.
To connect, I used the following:
import s3fs
from skimage import exposure
from PIL import Image, ImageStat
s3 = s3fs.S3FileSystem(client_kwargs={'endpoint_url': 'XXX'},
key='XXX',
secret='XXX')
I can retrieve an image from the s3 bucket as defined above and preprocess them using
infile = s3.open('test.jpg',"rb")
image = Image.open(infile)
img = np.asarray(image) #numpy.ndarray
img_eq = exposure.equalize_adapthist(img,clip_limit=0.03) #CLAHE
image_eq = Image.fromarray((img_eq * 255).astype(np.uint8)) #Convert back to image
To save the resulting image <image_eq> locally, would just be
image_eq.save("hello.jpg")
However, how do I save/write the resulting image into the s3fs filesystem instead?