Commensurate-incommensurate transition with frozen impurities