LucasTheIntern / SuperRes

Get superresolution from a stack of images using python
1 stars 0 forks source link

IndexError #1

Closed Thane5 closed 8 months ago

Thane5 commented 8 months ago

Hey, i'm having trouble getting this to run properly.

I imported the python dependencies, and added a file path to the script. But windows terminal shows this error:

PS C:\SuperRes-main> python superres.py
Importing images!
Upscaling images...
Traceback (most recent call last):
  File "C:\SuperRes-main\superres.py", line 168, in <module>
    superresolution(folder_path)
  File "C:\SuperRes-main\superres.py", line 81, in superresolution
    reference_image = upscaled_images[0]
                      ~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
PS C:\SuperRes-main>
LucasTheIntern commented 8 months ago

Hi! Sorry to hear you're having issues...

May I ask what format your images are? I know I've had success with jpg and png images. I've tried raw files as well, but I don't remember how that turned out.

Another possibility is that your CV2 installation is misbehaving. I'm running version 4.6.0 at the moment.

Thane5 commented 8 months ago

I used five jpegs from my camera. I also just installed opencv-python 4.6.0.66, but it gave me the same error.

LucasTheIntern commented 8 months ago

Ok, thanks!

Your terminal output makes it look like no images are actually being imported in the first place. The error is just saying that there is no first image to use as an alignment target.

Perhaps the directory is incorrect or not what the script expects... I just tried it in VS Code, and it worked fine for me. Your directory should look something like this: folder_path = r'C:\Users\yourusername\Downloads\ForSuperRes' Note that it does not have to be in your downloads folder (as long as python has read/write access to it), and the last folder can be named whatever you want. The directory should lead to a folder that contains nothing but the photos you want to process. In my case, the folder "ForSuperRes" contains ONLY five unmodified jpegs I captured with my phone. I've never tried a zipped folder, and I don't know if that would work.

Running the script in an interactive window yields:

Importing images!
Upscaling images...
Aligning image 1 of 5
Aligning image 2 of 5
Aligning image 3 of 5
Aligning image 4 of 5
Aligning image 5 of 5
Alignment finished!
Getting the median image...
Saving median image...
Ready for sharpness/brightness adjustment! Close the tkinter window to cancel.

After closing the tkinter window, the upscaled image is available in the original folder under the name "SUPERRES_med.png" alongside the original images.

Thane5 commented 8 months ago

Ah, i finally got it to work. I converted all my out-of-camera jpegs into PNG files, and then it suddenly generated an image. Interestingly, it seems to work fine with other jpegs - so there is probably something about the jpegs that my Fujifilm camera generates, that this program can not digest properly.

LucasTheIntern commented 8 months ago

Glad you got it working!

A quick search didn't turn up any results about python incompatibilities with Fujifilm cameras... If you ever figure out exactly what the issue was, I'd be happy to hear it!