-38

I think, this is one kind of abuse of people's rights.

The following routine subtract the mean value from the image making it sharper.

function pad = erase_mean(im, sz)    
    im = double(im);

    pad = floor(sz/2);
    [m,n,o] = size(im);

    mask = ones(sz,sz);

    for q=1:o       
        im(:,:,q)=double(im(:,:,q))-conv2(double(im(:,:,q)),mask,'same')./sz^2;

        mx=max(max(im(1+pad*2:m-pad*2,1+pad*2:n-pad*2,q)));

        im(:,:,q)=(im(:,:,q)./mx).*255;        
    end;

    mx = max(max(im(1+pad*2:m-pad*2,1+pad*2:n-pad*2,q)));
    im = uint8((im./mx(1)).*255);
    pad = im(1+pad*2:m-pad*2,1+pad*2:n-pad*2,:);

enter image description here

  • What is the purpose of variable sz in this routine?
  • pad is used as an integer and a matrix at the same time?
  • Is it illegal to ask for code explanation?
  • What more explanation could I provide? If I could provide more explanation, why would I post the question in the 1st place?

Accepted answer

Even the answer is being down-voted.

If sz is an scalar value, it defines the dimensions of the square matrix mask. It's more interesting to see what mask does, substract the mean value to catch the extreme values of the image, as explained in the kmdreko's answer.

If this question was not answerable, how could he answer and how could I accept the answer?

6
  • 11
    Note that no one claimed that "the question is not answerable". The tooltip for the downvote button says "This question does not show any research effort; it is unclear or not useful". Sep 3, 2018 at 15:22
  • 33
    "Abuse of people's rights"? Really? Come on... Sep 3, 2018 at 15:26
  • 13
    What "rights" would those be?
    – user2100815
    Sep 3, 2018 at 15:31
  • 1
    see also: What is the meta effect?
    – gnat
    Sep 3, 2018 at 17:09
  • 5
    I was the answerer to that question and OP changed the question so it now does not answer the new question. This is a reason that discourages me to answer questions, as it now seems pointless the time I devoted to read and provide an answer to what OP asked. How do mods proceed in these cases?
    – mrbolichi
    Sep 3, 2018 at 18:02
  • 3
    @mrbolichi a mod, or even a sufficiently-privileged user such as myself, could roll it back. I won't do it here because it's matlab and, lacking the technical skills, I would not vote/rollback or otherwise touch it. The best user to judge on possible rollbacks would be a high-rep matlab user. Not sure how you would go about finding one who could look at it:( Sep 3, 2018 at 23:33

1 Answer 1

30

What more explanation could I provide? If I could provide more explanation, why would I post the question in the 1st place?

When you write your next question, consider SO like you would an encyclopedia.

If an encyclopedic article on Matlab was entitled, What is the purpose of variable sz in this routine? would it have any significance? Well, clearly not.

The reason why I emphasize the title is it pinpoints the issue with the question itself. It is so localized that it will have no use for anyone else. There are millions of such functions in the public domain. Does each variable in each function need an independent explanation?

Of course, the people at SO are happy to help if they see evidence of you trying to work it out for yourself. One way you can achieve this is explain what you currently understand about the function and why the use of a particular variable seems questionable.

But that's not what you've done. You've provided a code dump and a highly localized question.

Not the answer you're looking for? Browse other questions tagged .