First step, convert whatever format the image is in to bw logic values, just use im2bw(yourImageValues).
It would take care of the small dots on that first image and whatever else you wanted.
My other approach for large lines is how I use to find scales in images automatically. Simply search the image for a white pixel, then see how far and left you can go with a while loop. If gits a certain theshold (i.e its more than 200 pixels long), add the pixel to a "toEraseVector", you can call it whatever you want, the idea is after you go through your image (should be almost instantaneous), you will call imfill for those selected images, and fill in the white area. You may need to inverse your bw logic values matrix to make sure the color works out and whats supposed to be black is black and vice-versa.
Let me know if you have questions, otherwise good luck!