Tags down


Do we use spatial filtering or frequency filtering for blurring, edge detection?

By : bibin baby john
Date : July 31 2020, 10:00 AM
To fix the issue you can do For any linear filter (convolution) you can obtain the same result using spatial domain and frequency domain computations. The convolution with a large kernel is usually more efficient to implement by multiplication in the frequency domain. The convolution with a small kernel is likely more efficient to implement directly in the spatial domain, unless one already has the frequency-domain representation (FFT) of the image available.
For any non-linear filter (everything else) you cannot use the frequency domain at all. Fourier analysis is limited to linear systems.
code :

Share : facebook icon twitter icon

Frequency vs spatial domain filtering

By : user3218798
Date : March 29 2020, 07:55 AM
I hope this helps . Assuming that you use imfilter, this function performs a convolution of the original image with the kernel (the gaussian filter image).
For going into the frequency domain and back, fast fourier transform (FFT) algorithms are used, and only an image multiplication is performed in the frequency domain.

spatial filtering by proximity in R

By : Vikram
Date : March 29 2020, 07:55 AM
around this issue I've written a new version of this function that no longer really follows rMaternII. The input can either be a SpatialPoints, SpatialPointsDataFrame or matrix object.
Seems to work well, but suggestions welcome!
code :
filterByProximity <- function(xy, dist, mapUnits = F) {
    #xy can be either a SpatialPoints or SPDF object, or a matrix
    #dist is in km if mapUnits=F, in mapUnits otherwise
    if (!mapUnits) {
        d <- spDists(xy,longlat=T)
    if (mapUnits) {
        d <- spDists(xy,longlat=F)
    diag(d) <- NA
    close <- (d <= dist)
    diag(close) <- NA
    closePts <- which(close,arr.ind=T)
    discard <- matrix(nrow=2,ncol=2)
    if (nrow(closePts) > 0) {
            while (nrow(closePts) > 0) {
                if ((!paste(closePts[1,1],closePts[1,2],sep='_') %in% paste(discard[,1],discard[,2],sep='_')) & (!paste(closePts[1,2],closePts[1,1],sep='_') %in% paste(discard[,1],discard[,2],sep='_'))) {
                discard <- rbind(discard, closePts[1,])
                closePts <- closePts[-union(which(closePts[,1] == closePts[1,1]), which(closePts[,2] == closePts[1,1])),]
        discard <- discard[complete.cases(discard),]
    if (nrow(closePts) == 0) {
pts <- readWKT("MULTIPOINT ((3.5 2), (1 1), (2 2), (4.5 3), (4.5 4.5), (5 5), (1 5))")

pts2 <- filterByProximity(pts,dist=2, mapUnits=T)

apply(as.data.frame(pts),1,function(x) plot(gBuffer(SpatialPoints(coords=matrix(c(x[1],x[2]),nrow=1)),width=2),add=T))

Bilateral Filtering preserves the edge, but I want the opposite, an edge -bluring filter?

By : EvaDelRey
Date : March 29 2020, 07:55 AM
it should still fix some issue I don't think there is one such filter! But if you want one you have to write one! Here is my Edge Smoothing algorithm! Hope you will find this useful!
code :
bool SmoothEdge( Mat mInput_Bgr,Mat &mOutput_Bgr, double amount, double radius, byte Threshold) 
        return 0;


    Mat mInput,mOutput;
    Mat mChannel[3];


    for (int i = 0; i < 3; i++)
        mInput= mChannel[i];
        SmoothEdgeSingleChannel(mInput,mOutput,amount, radius,Threshold); 

    return true;

bool SmoothEdgeSingleChannel( Mat mInput,Mat &mOutput, double amount, double radius, byte Threshold) 
        return 0;

    Mat mGSmooth,mDiff,mAbsDiff;
    mOutput = Mat(mInput.size(),mInput.type());


    threshold(abs(2* mDiff),mAbsDiff,Threshold,255,THRESH_BINARY_INV);



    return true;

int main(int argc, char* argv[])
    string FileName_S="Path\\Image.jpg";
    double m_Amount=1.5;
    double m_Radius=5.5;
    int m_Threshold=0;

    Mat mSource_Bgr,mSmoothEdge;
    mSource_Bgr= imread(FileName_S,1);


    imshow("Source Image",mSource_Bgr);
    imshow("Output Image",mSmoothEdge); 

How to perfom horizontal rank filtering for edge detection?

By : Dev Crafts
Date : March 29 2020, 07:55 AM
I wish this helpful for you I just tried a code to work for this particular image, but not a general one. Here we have the input image.
code :
a = imread('Izy.jpg');
b = imresize(a,0.5);
c = rgb2gray(b);
Gpx = edge(c,'canny');
L = bwlabel(Gpx,8);
imgstat = regionprops(L,'Area','Eccentricity');
area = [imgstat.Area];
ecc = [imgstat.Eccentricity];
label = find((area > 150) & (ecc < 0.95) & (ecc > 0.9));
logical_result = ismember(L,label);
[row, col] = ind2sub([size(c,1), size(c,2)],find(logical_result == 1));
result = c(min(row):max(row),min(col):max(col));

Edge Detection in Frequency Domain

By : maximino sy
Date : March 29 2020, 07:55 AM
To fix this issue There are a number of methods out there for this, and one in particular I'll mention is the concentration factor method for detecting edges in spectral signals.
However, these methods are typically used on continuous frequency signals and there's no reason to use this on images. It's slower than convolution kernel based approaches, like Sobel filters for Canny edge detection, and the literature is far more specialized for fields where only frequency based information is given, like in reconstruction from radar or MRI signals.
code :
>>> import numpy as np
>>> import cv2
>>> img = np.zeros((8, 8), dtype=np.float32)
>>> img[2:6, 2:6] = 1
>>> img
array([[ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  1.,  1.,  1.,  1.,  0.,  0.],
       [ 0.,  0.,  1.,  1.,  1.,  1.,  0.,  0.],
       [ 0.,  0.,  1.,  1.,  1.,  1.,  0.,  0.],
       [ 0.,  0.,  1.,  1.,  1.,  1.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]], dtype=float32)
>>> dct_coeff = cv2.dct(img)
>>> dct_coeff[2:6, 2:6] = 0
>>> hp_img = cv2.idct(dct_coeff)
>>> hp_img > 0.75
array([[False, False, False, False, False, False, False, False],
       [False, False, False, False, False, False, False, False],
       [False, False,  True,  True,  True,  True, False, False],
       [False, False,  True, False, False,  True, False, False],
       [False, False,  True, False, False,  True, False, False],
       [False, False,  True,  True,  True,  True, False, False],
       [False, False, False, False, False, False, False, False],
       [False, False, False, False, False, False, False, False]], dtype=bool)
Related Posts Related Posts :
  • name 'df' is not defined in box plot
  • Comparing dataframe columns
  • Can I Override Global Authentication for a Single Request Type in an ApiView using DRF?
  • Celery chain performances
  • Why am I getting "asynchronous comprehension outside of an asynchronous function"?
  • Creating a file from a docker container
  • doing too many write operations in django rest framework and postgres
  • How to change the order of bar charts in Python?
  • Pandas Data Frame manipulation
  • an undefined error in a simple python code- KeyError: '284882215'
  • Pandas split column in several columns throug string replacement or regex
  • how value is passed from __init__ method in pyhton as it dose not return anyhting
  • Dynamically inherit all Python magic methods from an instance attribute
  • Asking user to input certain information
  • how to test a deep learning model in a new dataset
  • Is np.fft.fft working properly? I am getting very large frequency values
  • How can you delete similar characters at the same positions in 2 strings
  • Does insert (at the end of a list) have O(1) time complexity?
  • Automatically Creating List of Dictionaries Based Upon Two Lists of Equal Length with Python
  • Discrete Cosine Transform (DCT) Coefficient Distribution
  • multiprocessing.Pool not running on last element of iterable
  • Python: sorting string non lexicographically
  • Render images from media directory Django
  • Cannot understand why more vectorization is slower than less vectorization in this case?
  • Django - Use a property as a foreign key
  • creating a function that loops if you do not enter the correct variables
  • Confused on how to store 3D matrices in HDF5 file in matlab?
  • TOTP: Can someone use the same otp within 30s and misuse it
  • is it possible to have 2 type hints for 1 parameter in Python?
  • Can someone explain what this Numpy array property is called?
  • Better way to add the result of apply (multiple outputs) to an existing DataFrame with column names
  • Selecting choice numbers
  • Create variables from list PYTHON
  • This code takes forever to run but doesn't give an error
  • "return" and "return None" behavior difference in generator
  • AttributeError: 'str' object has no attribute 'fbind' error using kivy in Python
  • Python not importing files when not inside conda environment
  • Is it possible to override a class' __call__ method?
  • Python library for live coordinated plotting in map
  • Pandas: counting consecutive rows with condition
  • How to define that a return type of method is an implementation of superclass
  • How can I print to the Visual Studio Code console in Portuguese?
  • Google Appengine Standard Python 2.7: Can't run Google Endpoints on localhost dev_appserver.py anymore
  • google appengine Unauthorized status 401
  • Don't understand cause of this IndentationError in my tic tac toe script
  • How to read in key-value pair from a json file as a pandas dataframe?
  • Can decorator decorate a recursive function?
  • How do I create a nested for loop where I have control of the initial loop index value
  • Unexpected error when creating a SQLite database using python
  • Pythonic way to write cascading of loops and if statements?
  • Python Beginner - Having trouble with multiple choice quiz program
  • Itertools return value NOT used in combinations
  • Return a list of words that contain a letter
  • From rows to columns using Peewee ORM
  • Parse large text document, to keep only "account number", and a specific keyword ("Market Value")
  • Cannot append to my list without getting a nonetype object error
  • Python Train Test Split
  • Optimizing following Python List of Dictionary operation with better solution
  • In Pandas merge colum1 value with colum2, both col data type is object and only few values are null in first column?
  • Python run multiple background loops independently
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org