Body: <p>Sorry, I have some background on AI, but very little experience.</p>
  <p>I am facing an image classification problem:</p>
  <p>I need to detect whether an image is background or not (images are always of the same size, which may vary from 15x15 pixels to 70x70 pixels, depending on the context)</p>
  <p>Is there any easy and light (and preferrably standard) algorithm to be applied to detect that?</p>
  <p>The model should have to be trained with only 10 (or more) background image examples, and 10 or less not background image examples.</p>
  <h3>Modification</h3>
  <p>The algorithm will be applied for detecting empty boxes at a chess board.</p>
  <p>Each box might be empty (background) or with a chess figurine (not background).</p>
  <p>The model or the image feature, will have to be extracted from a pair  <strong>[ image, FEN string ]</strong></p>
  <ul>
  <li>The image is a chess board image</li>
  <li>The FEN string is a string that defines univocaly the position of the figurines inside the chess board.</li>
  </ul>
  <p>The current algorithm is able to split the chess board into 64 separate boxes.</p>
  <p>So now is the turn to create a model that is able to decide whether a box is empty or not.</p>
  <p>There will be two kind of boxes (the white ones and the black ones).</p>
  <p>There are then, at most, 16 figurines per player (32 figurines).</p>
  <p>Hopefully, there will be more than 10 examples of empty white boxes, and 10 examples of empty black boxes.
  And hopefully, there will be at least one not background example for white and black boxes.</p>
  <p>So, the meaning of background in this case is: an uniform texture or flat color at the whole of the image.
  And not background, is an image with our background as background, but with any other overlapping shape as foreground.</p>
  <h3>Update (2024-03-03)</h3>
  <p>Thanks for your answer, Adrien.</p>
  <p>I have just done a look on your proposal.</p>
  <p>And, based on canny outputs got from an image set, I have inferred that the idea might work for a flat color background, but it is not so easy to distinguish whether the image is background or not based only basing on a canny output when the background is a texture.</p>
  <p>I have calculated the canny outputs using a code I found on the internet some years ago, and configuring the algorithm with different parameters.</p>
  <p>You can download the results here: <a href="https://frojasg1.com/stackOverflow/20240303.imageClassification/20240303.canny.7z" rel="nofollow noreferrer">https://frojasg1.com/stackOverflow/20240303.imageClassification/20240303.canny.7z</a></p>
  <p>Any other ideas are welcome!</p>
  <h3>Update 2024-03-17</h3>
  <p>They have asked me to attach some examples, and here they are:</p>
  <p><a href="https://frojasg1.com/stackOverflow/20240303.imageClassification/20240317.ChessBoardRecognitionPatterns.zip" rel="nofollow noreferrer">The examples</a></p>
  <p>They are organized in folders.</p>
  <p>All images in a particular folder, have the same board box size.</p>
  <p>There are some images in tiff format (tiff was chosen for avoiding loosing quality for compression).</p>
  <p>The name of files say which chess figurine they represent.</p>
  <p>There can be black or white figurines, over black or white board boxes, and the letters for those figurines are the initial letters (KQRBNP): King, Queen, Rook, Bishop, Knight and Pawn.</p>
  <p>The patterns that represent empty board boxes, have a name with four letters: WWWW for empty white board boxes, and BBBB for empty black board boxes.</p>
  <p>The examples in the zip file have been obtained automatically from automatic training of the chess position recognizer I programmed for my application, and I have not checked if all of them have been right identified, I hope so ...</p>
  <p>Well, those are the examples.</p>
  <p>I hope that helps for achieving the solution</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-02-23T09:09:13.490Z
Comments.Text: Could you elaborate on the description of your "background" . What is that visual feature that describes the background? Based on the description maybe the problem has to be redefined.
Comments.UserDisplayName: Arun Aniyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-02-23T10:53:15.883Z
Comments.Text: Well, the application for that image classifier, will be to detect, in a chess board context, whether a board box is empty or not.
  An empty board box, is filled with a texture, which may be a plain color, or a texture, which is not so easy to detect.
  The non background boxes, include a chess figurine, that would made the detection be: not background.
Comments.UserDisplayName: Francisco Javier Rojas
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-02-23T10:58:06.457Z
Comments.Text: My idea, would be to use some kind of image feature, which would not need many examples to be calculated, and then to use some kind of error measure, and a threshold, for the decision. But I do not know if that is possible, neither which feature, nor error measure algorithms to be used.
Comments.UserDisplayName: Francisco Javier Rojas
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-02-27T13:09:38.867Z
Comments.Text: You could try something like an edge detector (maybe canny algorithm?) If there is almost to no edge, it's backgroud, if there is some edges, if's a piece.
Comments.UserDisplayName: Adrien Nivaggioli
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-03-03T14:22:30.230Z
Comments.Text: Thank you Adrien suggesting an idea for solving the problem. I will update the body of my question to answer it more appropiately
Comments.UserDisplayName: Francisco Javier Rojas
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-03-03T17:38:22.673Z
Comments.Text: Can you provide examples of background and not background?
Comments.UserDisplayName: Marko Lalovic
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-03-17T16:37:39.087Z
Comments.Text: Hi Marko, sorry for the delay, I have been very busy
  
  I have just zipped the examples I have (they have been obtained automatically, from some automatic training for the chess position recognizer I programmed for my application and I have not checked if all of them are valid).
  
  I will update the text of the question to include a link to the zip with the examples.
Comments.UserDisplayName: Francisco Javier Rojas
Tags: <image-recognition>
Title: Image classification for two categories: background and not background
UserDisplayName: Francisco Javier Rojas
ThreadText: # Image classification for two categories: background and not background
  
  (Asked by: username_0 on 2024-02-21)
  
  Sorry, I have some background on AI, but very little experience.
  
  I am facing an image classification problem:
  
  I need to detect whether an image is background or not (images are always of the same size, which may vary from 15x15 pixels to 70x70 pixels, depending on the context)
  
  Is there any easy and light (and preferrably standard) algorithm to be applied to detect that?
  
  The model should have to be trained with only 10 (or more) background image examples, and 10 or less not background image examples.
  
  ### Modification
  
  The algorithm will be applied for detecting empty boxes at a chess board.
  
  Each box might be empty (background) or with a chess figurine (not background).
  
  The model or the image feature, will have to be extracted from a pair **[ image, FEN string ]**
  
  * The image is a chess board image
  * The FEN string is a string that defines univocaly the position of the figurines inside the chess board.
  
  The current algorithm is able to split the chess board into 64 separate boxes.
  
  So now is the turn to create a model that is able to decide whether a box is empty or not.
  
  There will be two kind of boxes (the white ones and the black ones).
  
  There are then, at most, 16 figurines per player (32 figurines).
  
  Hopefully, there will be more than 10 examples of empty white boxes, and 10 examples of empty black boxes.
  And hopefully, there will be at least one not background example for white and black boxes.
  
  So, the meaning of background in this case is: an uniform texture or flat color at the whole of the image.
  And not background, is an image with our background as background, but with any other overlapping shape as foreground.
  
  ### Update (2024-03-03)
  
  Thanks for your answer, Adrien.
  
  I have just done a look on your proposal.
  
  And, based on canny outputs got from an image set, I have inferred that the idea might work for a flat color background, but it is not so easy to distinguish whether the image is background or not based only basing on a canny output when the background is a texture.
  
  I have calculated the canny outputs using a code I found on the internet some years ago, and configuring the algorithm with different parameters.
  
  You can download the results here: <https://frojasg1.com/stackOverflow/20240303.imageClassification/20240303.canny.7z>
  
  Any other ideas are welcome!
  
  ### Update 2024-03-17
  
  They have asked me to attach some examples, and here they are:
  
  [The examples](https://frojasg1.com/stackOverflow/20240303.imageClassification/20240317.ChessBoardRecognitionPatterns.zip)
  
  They are organized in folders.
  
  All images in a particular folder, have the same board box size.
  
  There are some images in tiff format (tiff was chosen for avoiding loosing quality for compression).
  
  The name of files say which chess figurine they represent.
  
  There can be black or white figurines, over black or white board boxes, and the letters for those figurines are the initial letters (KQRBNP): King, Queen, Rook, Bishop, Knight and Pawn.
  
  The patterns that represent empty board boxes, have a name with four letters: WWWW for empty white board boxes, and BBBB for empty black board boxes.
  
  The examples in the zip file have been obtained automatically from automatic training of the chess position recognizer I programmed for my application, and I have not checked if all of them have been right identified, I hope so ...
  
  Well, those are the examples.
  
  I hope that helps for achieving the solution
  
  **Tags:** image-recognition
  > **Comments:**
  > **username_1**: Could you elaborate on the description of your "background" . What is that visual feature that describes the background? Based on the description maybe the problem has to be redefined.  
  > **username_0**: Well, the application for that image classifier, will be to detect, in a chess board context, whether a board box is empty or not. An empty board box, is filled with a texture, which may be a plain color, or a texture, which is not so easy to detect. The non background boxes, include a chess figurine, that would made the detection be: not background.  
  > **username_0**: My idea, would be to use some kind of image feature, which would not need many examples to be calculated, and then to use some kind of error measure, and a threshold, for the decision. But I do not know if that is possible, neither which feature, nor error measure algorithms to be used.  
  > **username_2**: You could try something like an edge detector (maybe canny algorithm?) If there is almost to no edge, it's backgroud, if there is some edges, if's a piece.  
  > **username_0**: Thank you Adrien suggesting an idea for solving the problem. I will update the body of my question to answer it more appropiately  
  > **username_3**: Can you provide examples of background and not background?  
  > **username_0**: Hi Marko, sorry for the delay, I have been very busy  I have just zipped the examples I have (they have been obtained automatically, from some automatic training for the chess position recognizer I programmed for my application and I have not checked if all of them are valid).  I will update the text of the question to include a link to the zip with the examples.  
  
  ---
  
  ## 0 answers
  
  