Let "Th" be the threshold level between foreground and background -- the point at which the gray of the foreground has become bright enough white to be considered background. Then,
will be a logical array "mask" that is true for the foreground locations.
That's as far as you can get without changing any pixel values.
What kind of data structure were you thinking of that had the background removed? MATLAB cannot have irregularily-shaped arrays. You can construct rectangular arrays that have the original values in all of the foreground locations, but something has to be in the background locations.
Best Answer