How to detect a specific image object and the crop object from the input images

5 views (last 30 days)

Hi, I have solar panel cell images taken from various resolution cameras, I want to detect a cell in the input Image and find out that specific object(cell) inside the input image, How i can do this?? I need to crop cell once it is detected, here is an example, I need to separate out cells based on black rectangle around cell.

Accepted Answer

Image Analyst
Image Analyst on 15 Jul 2018
Muhammad:
Attached is a full demo that works with your image that you posted. It assumes that the band height is fixed - all tiles within one horizontal band seem to be within the same pair of row numbers. Then it gets the average horizontal profile and looks for little dark lines that separate the 10 different tiles. Then it goes through the band cropping out each tile and writing it to disk. Below is a screen shot after it has found the last tile in band #6, but the screen will update at every single tile. There are tons of comments and helpful pictures to show you what it's doing. Let me know if this works for you. If it doesn't work for some other image, post the image it fails with so we can determine why its different than the only image you posted so far.
  7 Comments
Image Analyst
Image Analyst on 17 Jul 2018
You could ask the user with inputdlg() how many rows are in this image, or else you could look at the average vertical profile, then smooth it and subtract it to find the peaks - much like I already did to find the divisions horizontally. The code is already in there, just copy it and adapt it to work on the vertical profile instead of the horizontal profile.
Muhammad Irfan
Muhammad Irfan on 18 Jul 2018
There are too many peaks in the difference signal in case of vertical profiles because of lines within the cells. Can you suggest any method through which I can get only the edge peaks for each cell ??

Sign in to comment.

More Answers (3)

Image Analyst
Image Analyst on 14 Jul 2018
Don't you have these 60 images "taken from various resolution cameras"?
Or is all you have one gigantic image where someone unfortunately stitched them all together? And if so, why can't you just use imcrop() to chop the image into 10 columns and 6 rows?
  1 Comment
Muhammad Irfan
Muhammad Irfan on 14 Jul 2018
No this is single image I have a dataset of 9K+ images.I need to write a script so that I can separate all cells from 9000+ images.Using imcrop it will be hard.I need to detect images in very fine manner.Some images have very thin edges to determine uniqueness of one cell from other.

Sign in to comment.


Matt J
Matt J on 15 Jul 2018
Edited: Matt J on 15 Jul 2018
My strategy would be as follows. I demonstrate with a somewhat cropped and binned version (attached) of your original image. First do some enhancement of the image to emphasize the horizontal and vertical lines over the background,
A=imread('Panels.png');
A=medfilt2(A,[10,10])-A;
A([1,end],:)=max(A(:));
A(:,[1,end])=max(A(:));
%%enhance columns
B=A; d=ones(10,1);
B=imerode(B,d);
%%enhance rows
C=A;
C=imerode(C,d.');
D=(B+C); %combine
Then, because you know the approximate dimensions of the cells, you can pick out a box enclosing the first cell
OneCell=D(1:130,1:130);
figure(1);
imagesc(OneCell)
Then you take row-wise and column-wise means of this cell to generate 1D profiles. The spikes in these profiles tell you the row/column locations of the horizontal/vertical lines, from which you can determine the boundaries of the cell more precisely and then crop. Knowing the boundaries of the first cell, you also then know the upper left coordinates of its neighbors and can do similar searches for them, and so on...
figure(2);
subplot(2,1,1);bar(col)
subplot(2,1,2);bar(row)

Huzaifa awan
Huzaifa awan on 20 Jul 2018
i want help in same issue
  6 Comments
Huzaifa awan
Huzaifa awan on 22 Jul 2018
i run this code run fine but when i create .exe file it give me error .i only request you sir to help me on this issue

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!