Accurately detecting irregularities in the media — thermal asperities and delamination — and mapping them out from further usage is critical to prevent data loss and minimize head disk interaction (HDI). Defect growth is a common concern in hard disk drives (HDD) and the immediate vicinity of media defects are also mapped out to provide sufficient protection against defect growth. A class of media defects that prove more complex to protect against defect growth is scratches on the media. Margining a media scratch involves filling in the gaps between the components of a scratch and margining the vicinity of the scratch in the defect growth direction. While Hough transform based techniques and deeplearning models have been developed to identify media patterns, they cannot be implemented in the hard disk drive firmware due to memory and computational limitations. Here, we present a computationally simple and efficient alternative to identify scratches on the media by combining clustering and an iterative parameter estimation to fit a line to the scratch in noisy conditions. The result is a method that is capable of modeling linear, spiral and parabolic scratches on a media and fill gaps in the scratch and extend the margining at either end of the scratch.