I want to create a module that fetches images from directories and display it under the heading of directory_name.
For this purpose which CMS is better.... Drupal, Wordpress or joomla..or something else?
In terms of selecting a CMS, I don't think you would want to do it based solely on being able to build a new picture gallery for it. Even if you start looking at what picture galleries are available in each CMS, there are other things you would want to consider. If this is the only thing that you ever expect to do with the CMS, then you might want to look for something light-weight rather than using a sledgehammer to kill a fly. You also want to look at the learning curve involved in setting up each one and the ease of maintenance. If you are going to maintain this on your own, it is just your learning curve. If you will be involving anyone else, then you have to consider their abilities as well.
I have used Website Baker for years because it is pretty easy to setup and maintain. I have customized templates and applications but I never built one from scratch because I didn't really have the need and I didn't want to take the time (to learn all the requirements and then build it). I also found Wordpress pretty straightforward but somewhat limited compared to a full-blown CMS. I found Joomla somewhat more complicated to learn but once you're over it, then it's probably ok. You will probably have a wider range of application and plug-in options with the more popular CMS's.
Unless you have a specific need for a CMS that you didn't mention, you can also use a standalone picture gallery like Coppermine. Depends on your full needs.