Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7678579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:40:48+00:00 2026-05-31T17:40:48+00:00

The input is a spectrum with colorful (sorry) vertical lines on a black background.

  • 0

spectrum

The input is a spectrum with colorful (sorry) vertical lines on a black background. Given the approximate x coordinate of that band (as marked by X), I want to find the width of that band.

I am unfamiliar with image processing. Please direct me to the correct method of image processing and a Python image processing package that can do the same.


I am thinking PIL, OpenCV gave me an impression of being overkill for this particular application.

What if I want to make this an expert system that can classify them in the future?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:40:49+00:00Added an answer on May 31, 2026 at 5:40 pm

    I’ll give a complete minimal working example (as suggested by sega_sai). I don’t have access to your original image, but you’ll see it doesn’t really matter! The peak distributions found by the code below are:

    Mean values at: 26.2840960523 80.8255092125

    import Image
    from scipy import *
    from scipy.optimize import leastsq
    
    # Load the picture with PIL, process if needed
    pic         = asarray(Image.open("band2.png"))
    
    # Average the pixel values along vertical axis
    pic_avg     = pic.mean(axis=2)
    projection  = pic_avg.sum(axis=0)
    
    # Set the min value to zero for a nice fit
    projection /= projection.mean()
    projection -= projection.min()
    
    # Fit function, two gaussians, adjust as needed
    def fitfunc(p,x):
        return p[0]*exp(-(x-p[1])**2/(2.0*p[2]**2)) + \
            p[3]*exp(-(x-p[4])**2/(2.0*p[5]**2))
    errfunc = lambda p, x, y: fitfunc(p,x)-y
    
    # Use scipy to fit, p0 is inital guess
    p0 = array([0,20,1,0,75,10])
    X  = xrange(len(projection))
    p1, success = leastsq(errfunc, p0, args=(X,projection))
    Y = fitfunc(p1,X)
    
    # Output the result
    print "Mean values at: ", p1[1], p1[4]
    
    # Plot the result
    from pylab import *
    subplot(211)
    imshow(pic)
    subplot(223)
    plot(projection)
    subplot(224)
    plot(X,Y,'r',lw=5)
    show()
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

input is a string (var str) something like this: <<hello there//abcd//1234>> I want to
Input: The customer claims that the application (.NET) when querying for some data returns
Input: I want to remove double space from textbox. Output: I want to remove
Input: total cost. Output: all the combinations of levels that give the desired cost.
// input, output, i, and k are uint16_t type // It is assured that
INPUT <logs> <logentry revision=648> <author>nshmyrev</author> <date>2008-09-21T19:43:10.819236Z</date> <paths> <path action=M>/trunk/po/ru.pi</path> </paths> <msg>2008-09-21 Nickolay V. Shmyrev
Input: 1) A huge sorted array of string SA; 2) A prefix string P;
Input @StartDate = '01/25/2010' @EndDate = '02/06/2010' I have 2 CTEs in a stored
Input : {5, 13, 6, 5, 13, 7, 8, 6, 5} Output : {5,
Input: SHC 111U,SHB 22x,, SHA 5555G Needed output: SHB 22X, SHC 111U, SHA 5555G

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.