Skip to content

Commit

Permalink
v 0.3 with lossless intermediate images
Browse files Browse the repository at this point in the history
  • Loading branch information
codecliff committed May 19, 2024
1 parent ceb5f7e commit d877dce
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 126 deletions.
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,18 @@ Beware- Unlike a phone app, PhotoGlimmer gives you full control of the segmentat


<p align="center">
<img width="1000" height="526" src="photoglimmer_screenshot_1000px.png", alt= "Screenshot of PhotoGlimmer image editor"/>
<br> Photo Credit: <a href="https://www.flickr.com/photos/tomvereenooghe/#">Flickr cc </a>
<img width="1000" height="526" src="screenshot_photoglimmer_03", alt= "Screenshot of PhotoGlimmer image editor"/>
<br> Photo Credit: <a href="https://www.flickr.com/photos/portishead520/16524721706/#">Flickr cc </a>
</p>

# Samples

<p align="center">
<img width="1000" height="666" src="photoglimmer_collage_smaller.jpg", alt= "Sample results for PhotoGlimmer image editor"/>
<br> Photo Credit: <a href="https://www.flickr.com/photos/portishead520/16524721706/#">Flickr cc </a>
</p>



# Features
- **Smart people identification:** PhotoGlimmer's intelligent algorithms demarks people and background in an image
Expand All @@ -54,7 +62,7 @@ Beware- Unlike a phone app, PhotoGlimmer gives you full control of the segmentat

- ** Foreground/People/Face Lighting**:

- ** Background Illumination **
- ** Background Illumination/Darkening **

- ** Background Defocus (Blur) **

Expand Down Expand Up @@ -103,7 +111,7 @@ So, if you are using the .deb or .AppImage version, you need to have only **Pyth
## Tested On:
- Ubuntu 20.04,22.04
- Fedora Linux 35 (VM, 4 GB RAM)
- Windows10
- Windows11



Expand Down Expand Up @@ -181,10 +189,10 @@ Follow these steps to install dependencies and run PhotoGlimmer :


## Acknowledgments:
- [Mediapipe](https://developers.google.com/mediapipe)
- [Opencv](https://opencv.org/)
- [PyQtDarkTheme](https://github.com/5yutan5/PyQtDarkTheme)
- [PyExif](https://pypi.org/user/edleafe/#)
- [Mediapipe](https://developers.google.com/mediapipe){:target="_blank"}
- [Opencv](https://opencv.org/){:target="_blank"}
- [PyQtDarkTheme](https://github.com/5yutan5/PyQtDarkTheme){:target="_blank"}
- [PyExif](https://pypi.org/user/edleafe/){:target="_blank"}
- StackOverflow contributors (links in source code)


Expand Down
Binary file added photoglimmer_03_screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added photoglimmer_collage_smaller.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot_photoglimmer_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions src/photoglimmer/photoglimmer_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def initializeImageObjects():
def setupWorkingImages(scaledimg_bgr):
global scaledImgpath, resultImgPath
scaledImgpath = os.path.join(tempdirpath, "working_image.jpg")
cv2.imwrite(scaledImgpath, scaledimg_bgr)
cv2.imwrite(scaledImgpath, scaledimg_bgr, params=[cv2.IMWRITE_JPEG_QUALITY, 100])
resultImgPath = os.path.join(tempdirpath, fname_resultimg)
shutil.copyfile(src=scaledImgpath, dst=fgImgpath)
shutil.copyfile(src=scaledImgpath, dst=bgImgpath)
Expand Down Expand Up @@ -89,7 +89,7 @@ def tweakAndSaveImage( sourceimg_bgr , imglayer_param):
value_fact=imglayer_param.brightness)
if currImg.denoise_it:
result_bgr = deNoiseImage(result_bgr )
cv2.imwrite( filename=imglayer_param.imgpath, img=result_bgr )
cv2.imwrite( filename=imglayer_param.imgpath, img=result_bgr ,params=[cv2.IMWRITE_JPEG_QUALITY, 100] )
return result_bgr


Expand All @@ -99,7 +99,7 @@ def blurAndSaveMask(imglayer_param,mask_graybgr, originalImage=False ):
blur_edge_tmp = int(imglayer_param.blur_edge/scaleFactor)
blurred_mask_graybgr = cv2.blur(mask_graybgr, (blur_edge_tmp, blur_edge_tmp),
anchor=(-1,-1),borderType= cv2.BORDER_DEFAULT)
cv2.imwrite(os.path.join(tempdirpath, fname_maskImgBlurred), blurred_mask_graybgr)
cv2.imwrite(os.path.join(tempdirpath, fname_maskImgBlurred), blurred_mask_graybgr, params=[cv2.IMWRITE_JPEG_QUALITY, 100])
return blurred_mask_graybgr


Expand All @@ -126,7 +126,7 @@ def createMaskedBrightness(sourceimg_bgr, maskimgimg_graybgr ,
ImgParams.blendweight_img1)
if ImgParams.postprocess_it:
addWted_bgr=splineStretch(addWted_bgr)
cv2.imwrite(filename=resultImgPath, img= addWted_bgr)
cv2.imwrite(filename=resultImgPath, img= addWted_bgr, params=[cv2.IMWRITE_JPEG_QUALITY, 95])
return addWted_bgr


Expand Down Expand Up @@ -198,7 +198,7 @@ def saveTransparentImage(imgbgr, mask_graybgr , outfpath:str=None):
im_gbra= createTrasnparentImage(imgbgr=imgbgr,
blurredmaskbgr= mask_graybgr)
if outfpath:
cv2.imwrite(outfpath, im_gbra)
cv2.imwrite(outfpath, im_gbra, params=[cv2.IMWRITE_JPEG_QUALITY, 100])
return im_gbra


Expand Down
4 changes: 2 additions & 2 deletions src/photoglimmer/photoglimmer_masking.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def createSegmentationMask_Improved(imgpath, thresh,
# https://stackoverflow.com/a/60869657/5132823
img_cropped= image_copy_bgr[Y:Y+H, X:X+W]
croppedimgpath= os.path.join(tempdirpath,"img_cropped.jpg")
cv2.imwrite(croppedimgpath, img_cropped)
cv2.imwrite(croppedimgpath, img_cropped, params=[cv2.IMWRITE_JPEG_QUALITY, 100])
croppedimg_mask_graybgr= __createSegmentationMask( croppedimgpath, thresh)
mask_image_graybgr[Y:Y+H, X:X+W] = croppedimg_mask_graybgr
cv2.imwrite(os.path.join(tempdirpath,fname_maskImg), mask_image_graybgr)
cv2.imwrite(os.path.join(tempdirpath,fname_maskImg), mask_image_graybgr, params=[cv2.IMWRITE_JPEG_QUALITY, 100] )
return mask_image_graybgr
Loading

0 comments on commit d877dce

Please sign in to comment.