Thank you very much Sir for this lecture. Here is my question. How can I design this code in such a way without specifying file location so everyone can run it on his computer and access data from his directory
Not sure what exactly you're asking for. Do you want to deploy your code so others can use it? If so, you need to convert your code into an application. If you are familiar with Docker technology then look at apeer.com and see if you can create applications (modules) out of your code.
I have one question. When the code is starting read the images from the file, it is not reading in order. First it reads image_1 then image_10,.....,image_20,image_2,.... But I need the order of images. Would you please suggest me to remove this issue?
It reads images based on file names. One way to make them in the sequence you want is to rename your original files. Or you can write a few lines of code in python to first read file names, e.g. into a Pandas dataframe. Then you can sort the dataframe however you want it to read the files and then read files based on the names from your dataframe.
Thanks a lot for this video, I have a small issue which I am facing. I am extracting the PDF table/nested table data in python using Tabula. Could you please let me know how to user for loop activity for this scenario where I could be able to read all the PDF data from the specific folder and the create a CSV with the same name as PDF. Eg: 3 PDF files are there as (A.pdf, B.pdf, C.pdf) reading all pdf and creating the excel with the same name A, B, and C) :)
Are you asking about reading a file, doing some stuff and then saving the output with same file name but different extension. In that case this video and the next one should have answered it. Use glob to read files, within the for loop do your operation using Tabula and assign same name to the output from Tabula that you plan on saving. Now continue the loop to read the next file and perform same operations.
Thanks your tutorials are great and very detailed. I have a task I need to do which is to count the number of files in each class of dog breed files. Plot the results so that I can generate a frequency distribution of the number of images I have in each dog breed class. Do you have any tutorial of this? I found all the different dog breed classes with classes=os.listdir('dogImages/train'). With one example as '119.Petit_basset_griffon_vendeen'. Not sure how I can use this list of classes with the substring to match the filenames. Count the number of matches and store the list of classes and its number of matches in a dataframe. There after I can plot a frequency distribution for the classes. Would you have a suggestion on how to do this?
If you are trying to count the number of files starting with or containing some specific text then you can search for those files and capture the names as a list. Then look at the length of each list to count the total number of files in each class. Then you can capture them into a pandas dataframe and plot. Here is a couple of lines for the first part. import glob import pandas as pd b_list = glob.glob('images/b*.*') #Rerurns a list of file names starting with b c_list = glob.glob('images/c*.*') #Rerurns a list of file names starting with c h_list = glob.glob('images/h*.*') #Rerurns a list of file names starting with h b = len(b_list) #Number of files starting with b c = len(c_list) h = len(h_list)
What are you using to view the image? If it is pyplot from matplotlib then please look into color maps. The default colormap of pyplot is not gray, so it makes your image appear colorful but your data is still 'gray' as you will notice that the numpy array itself does not have 3 channels. In any case, if you want to view image in gray then add this to your plt.imshow command... cmap='gray'. SO if your image is called img then it would be: plt.imshow(img, cmap='gray')
This answer is really relevant to what I am busy searching for. All I need is to use python and its libraries to design a program that will read a serious of drone Images and detect, adjust, correct and register the images to become a single seamless image of search and rescue operation. This the intention. So I beg that anything relevant to this I am interested. I need help because I am from Geomatics background
The best way to register multiple images is by using pystackreg library. Please watch our video on this topic (Tutorial 47). You can write a for loop to register images but the best approach would be to stack all images into a single tiff file and then use pystackreg for registration. That way you can register not only by individual images but also by calculating mean of a stack of images. You can find more information here: pypi.org/project/pystackreg/
One way to do this is by adding all images into a numpy array and then selecting images from 50 and above from the array. Example, for 100 color images that are 256x256 in size your numpy array would be (100, 256, 256, 3). Other way is to capture all file names from glob into a list and then select files from the list for further processing.
You cannot write .czi files, yet. Zeiss may publish a library soon to allow for czi writing. As of now you can convert from czi to tif. If you want to write czi files, look into downloading the free version of ZEN (called ZEN Lite).
I guess it read any type of image, you can specified de extension of your archive like this path_firs = '\\Users\\tester\\Desktop\\Myfiles\\' all_files_csv = glob.glob(path_firs + '*.csv') At the end of all_files_csv you can change the extension (csv) to whatever you want
Follow the same process as in this video except when it comes to processing images you are going to use easyocr to extract text from images. You will be capturing result from each image and write to a pandas dataframe.
Here are a few lines of code to read multiple images in a folder (images folder), perform OCR and capture text from each image into a dataframe. You can save the dataframe to csv if you want. #Read multiple images in a directory, extract text using OCR and capture it in a pandas dataframe. import cv2 import glob import pandas as pd #select the path path = "images/*.*" img_number = 1 reader = easyocr.Reader(['en']) #English df=pd.DataFrame() for file in glob.glob(path): print(file) #just stop here to see all file names printed img= cv2.imread(file, 0) #now, we can read each file since we have the full path results = reader.readtext(img, detail=0, paragraph=True) #Set detail to 0 for simple text output df = df.append(pd.DataFrame({'image': file, 'detected_text': results[0]}, index=[0]), ignore_index=True) img_number +=1
this was awesome
really feels like I am learning something
That is the goal, to make sure you learn :)
Many thanks for this series.. Excellent quality ..:) Please make more content, this is going really cool!
More to come!
Thank you very much Sir for this lecture. Here is my question. How can I design this code in such a way without specifying file location so everyone can run it on his computer and access data from his directory
Not sure what exactly you're asking for. Do you want to deploy your code so others can use it? If so, you need to convert your code into an application. If you are familiar with Docker technology then look at apeer.com and see if you can create applications (modules) out of your code.
thank you sir for this amazing video.
I have a question , how to load images from two folder in for loop and do something with it .
Thanks Sir. Time saving and life saving.....
I have one question.
When the code is starting read the images from the file, it is not reading in order. First it reads image_1 then image_10,.....,image_20,image_2,....
But I need the order of images.
Would you please suggest me to remove this issue?
It reads images based on file names. One way to make them in the sequence you want is to rename your original files. Or you can write a few lines of code in python to first read file names, e.g. into a Pandas dataframe. Then you can sort the dataframe however you want it to read the files and then read files based on the names from your dataframe.
Thanks a lot for this video, I have a small issue which I am facing. I am extracting the PDF table/nested table data in python using Tabula. Could you please let me know how to user for loop activity for this scenario where I could be able to read all the PDF data from the specific folder and the create a CSV with the same name as PDF.
Eg: 3 PDF files are there as (A.pdf, B.pdf, C.pdf) reading all pdf and creating the excel with the same name A, B, and C) :)
Are you asking about reading a file, doing some stuff and then saving the output with same file name but different extension. In that case this video and the next one should have answered it. Use glob to read files, within the for loop do your operation using Tabula and assign same name to the output from Tabula that you plan on saving. Now continue the loop to read the next file and perform same operations.
Thanks your tutorials are great and very detailed. I have a task I need to do which is to count the number of files in each class of dog breed files. Plot the results so that I can generate a frequency distribution of the number of images I have in each dog breed class.
Do you have any tutorial of this?
I found all the different dog breed classes with classes=os.listdir('dogImages/train'). With one example as '119.Petit_basset_griffon_vendeen'. Not sure how I can use this list of classes with the substring to match the filenames. Count the number of matches and store the list of classes and its number of matches in a dataframe.
There after I can plot a frequency distribution for the classes. Would you have a suggestion on how to do this?
If you are trying to count the number of files starting with or containing some specific text then you can search for those files and capture the names as a list. Then look at the length of each list to count the total number of files in each class. Then you can capture them into a pandas dataframe and plot. Here is a couple of lines for the first part.
import glob
import pandas as pd
b_list = glob.glob('images/b*.*') #Rerurns a list of file names starting with b
c_list = glob.glob('images/c*.*') #Rerurns a list of file names starting with c
h_list = glob.glob('images/h*.*') #Rerurns a list of file names starting with h
b = len(b_list) #Number of files starting with b
c = len(c_list)
h = len(h_list)
I have error with out of range :(, don't know why. I only can call li[0] but it's error with li[1], even I have 2 files in the folder
Thank you very much. Your tutorial helped me a lot!
Glad it helped!
how can i save and then load the list Or dict of images in another file like matlab there is save X X and then there is load X ,, Please
thanks so much for this valuable video. I was wondering if you could make a video for 'Mask-RCNN' for segmenting images. Thank you so much!
Can I use glob.glob() if my files are not in the same directory?
I was trying the recursive option but it never works, so i change to use os.walk
os.walk is also a good way to achieve the task.
how can i combine netcdf files from multiples directories to one single netcdf
Thank you, sir! Great tutorial
Glad it was helpful!
would you give me some hit why my_list has[None, None, None, None, None, None, None, None, None, None] although I run the for loop? I'm bit lost
It says none as it cannot find any images. Please make sure you verify the path and also your current working directory.
sir i have a grey image and when I am reading it with io.imread its showing image in bluish color. please tell me how read exact image ?
thank you
What are you using to view the image? If it is pyplot from matplotlib then please look into color maps. The default colormap of pyplot is not gray, so it makes your image appear colorful but your data is still 'gray' as you will notice that the numpy array itself does not have 3 channels. In any case, if you want to view image in gray then add this to your plt.imshow command... cmap='gray'. SO if your image is called img then it would be: plt.imshow(img, cmap='gray')
How do we use this to find all the files in different directories?
Thank you. It helps me a lot.
Thank you sir. I have a question. what if one don't need to read all the 10 images just like want to load 5 images. Then what should we do?
You can use for or while loop to loop thorough each image and exit when a predefined count is reached. Please watch the videos on for and while loops.
@@ZEISS_arivis Thank you so much sir for your reply. Definitely gonna check your other videos. They are really great.
Thank you very much
thank you so much sir..
This answer is really relevant to what I am busy searching for. All I need is to use python and its libraries to design a program that will read a serious of drone Images and detect, adjust, correct and register the images to become a single seamless image of search and rescue operation. This the intention. So I beg that anything relevant to this I am interested. I need help because I am from Geomatics background
The best way to register multiple images is by using pystackreg library. Please watch our video on this topic (Tutorial 47). You can write a for loop to register images but the best approach would be to stack all images into a single tiff file and then use pystackreg for registration. That way you can register not only by individual images but also by calculating mean of a stack of images. You can find more information here: pypi.org/project/pystackreg/
how to take 5 img from 10 img of a specific number inside folder
Lets say I have 100 images in a directory (000.jpg upto 100.jpg), but I only wan to process 050.jpg upto 100.jpg. How do I do that with glob?
One way to do this is by adding all images into a numpy array and then selecting images from 50 and above from the array.
Example, for 100 color images that are 256x256 in size your numpy array would be (100, 256, 256, 3).
Other way is to capture all file names from glob into a list and then select files from the list for further processing.
Thank you, Sir!
You are welcome!
Thank you. it really helped me.
Glad it helped!
Hello, how would I batch convert hundreds of .tif files to .czi?
You cannot write .czi files, yet. Zeiss may publish a library soon to allow for czi writing. As of now you can convert from czi to tif. If you want to write czi files, look into downloading the free version of ZEN (called ZEN Lite).
good video
Glad you enjoyed
Glob only read jpg images? I'm using imutils
I guess it read any type of image, you can specified de extension of your archive like this
path_firs = '\\Users\\tester\\Desktop\\Myfiles\\'
all_files_csv = glob.glob(path_firs + '*.csv')
At the end of all_files_csv you can change the extension (csv) to whatever you want
@@vargas4762 Thanks but imutils Is ok
How to import cv2 what is that in python? i want to read text file?
Please watch all videos as a course, otherwise things may not make sense.
By the way, cv2 (opencv) is for reading images, not text files.
use pandas to read txt files..
it is not possible for me to import cv2!!
Please make sure you have installed opencv.
please help me , i want to perform easyocr on 1 million images , please help me ,please
Follow the same process as in this video except when it comes to processing images you are going to use easyocr to extract text from images. You will be capturing result from each image and write to a pandas dataframe.
Here are a few lines of code to read multiple images in a folder (images folder), perform OCR and capture text from each image into a dataframe. You can save the dataframe to csv if you want.
#Read multiple images in a directory, extract text using OCR and capture it in a pandas dataframe.
import cv2
import glob
import pandas as pd
#select the path
path = "images/*.*"
img_number = 1
reader = easyocr.Reader(['en']) #English
df=pd.DataFrame()
for file in glob.glob(path):
print(file) #just stop here to see all file names printed
img= cv2.imread(file, 0) #now, we can read each file since we have the full path
results = reader.readtext(img, detail=0, paragraph=True) #Set detail to 0 for simple text output
df = df.append(pd.DataFrame({'image': file, 'detected_text': results[0]}, index=[0]), ignore_index=True)
img_number +=1
can you please provide the codes
Yes, working on it, please give us a week.
YOR GITHUB IS FILLED WITH RELIABLE CODE SIR...
Thank you.