Hello Dewandra,
I understand that you are facing an error with the ‘imread’ function.
I tried running your code with a folder of sample images and it ran without errors for me. This could mean that the issue lies with the images or their paths and not with your code. I would suggest you to try the following methods to resolve this error:
- Ensure the file format of all the images is supported by ‘imread’ (e.g., JPG, PNG, BMP, GIF). If the file is in a format not supported by imread, you can convert it to a supported format using an external tool.
- Ensure that the image is not empty or corrupted. Check if you can open and view the image outside MATLAB.
- Verify that the file path in ‘namafile’, for every iteration, is correct and that the file exists at that location.
- Ensure that MATLAB has read access to the file and directory.
Refer to the following documentation to understand more about the formats allowed by 'imread' -
I hope this helps.