How to Crop single image before calling torchvision.utils.save_image, If I am using PIL lib Image.crop(....) method then image quality degrade.
Open
Nobody has claimed this yet.
module: utils
- Dominant language
- Python
- Stars
- 17.9k
- Forks
- 7.3k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 13
Description
vutils.save_image(fixed_fake.data,outputpath , normalize=True)
print("output path",outputpath)
img = Image.open(outputpath)
noOfRow = 5
noOfColumn = 8
x1 = 2
y1 = 2
x2 = 130
y2 = 130
folder = file_batch
for i in range(0, noOfColumn):
dest_dir = file_batch[i].split("/")[7]
if not os.path.exists(outf+"/"+dest_dir):
os.mkdir(outf+"/"+dest_dir)
for j in range(1, noOfRow + 1):
area = (x1, y1, x2, y2)
cropped_img = img.crop(area)
imgName = "{}{}".format(i, j)
cropped_img.save(os.path.join(outf+dest_dir,filename))
y1 = y1 + 130
y2 = y2 + 130
x1 = x1 + 130
x2 = x2 + 130
y1 = 2
y2 = 130
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided workflow with torchvision.utils.save_image, PIL Image.open, Image.crop, and cropped_img.save. Compare the saved image before and after cropping to determine where quality changes; done means the source of the degradation is identified and the expected image quality or handling is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100