function finalchange = process(final, p)
    [row, col] = size(final);
    minpix = 0;
    maxpix = 0;

    % min/max/average determination
    for a = 1:row
        for b = 1:col
            if (final(a,b) > maxpix)
                maxpix = final(a,b);
            elseif (final(a,b) < minpix)
                minpix = final(a,b);
            end
        
        end
    end

    tablepixel = zeros((maxpix - minpix),2);

    for (h = 0:(maxpix - minpix))
        tablepixel(h+1,1) = minpix + h;
    end


    for a = 1:row
        for b = 1:col
            rowvalue = final(a,b);
            tablepixel(rowvalue, 2) = tablepixel(rowvalue, 2) + 1;
        end
    end
    
    maxrelpix = 0;

    for a = 0:(maxpix-minpix)
        if (tablepixel((maxpix-minpix)-a,2) > (0.005*row*col))
            maxrelpix = tablepixel((maxpix-minpix)-a,1);
            break
        end
    
    
    end


    bleh = sum(tablepixel, 1);
    tablepixel
    [m,n] = size(tablepixel);
    left = ones(1, m);
    right = ones(2,1);
    total = dot(tablepixel(:,1),tablepixel(:,2));
    averagepixel = total/bleh(1,2)


    % Height Processing 

    finalchange = final;

    % standard average height
    % results in "islands" of error for bulbous


    for a = 1:row
        for b = 1:col
        
            temp = 100*(maxrelpix - double(finalchange(a,b)))/maxrelpix;
            if (temp > p) 
                finalchange(a,b) = 0;
            else 
                finalchange(a,b) = 256;
            end
        end
    end



end
