resdet icon indicating copy to clipboard operation
resdet copied to clipboard

[Request] Output corresponding absolute value spectrum with overlay

Open BuyMyMojo opened this issue 7 months ago • 6 comments

I have now been using spec for a little bit and love it I would love to see an output option for resdet that could output the spectrum image with some form of overlay.

To be entirely transparent my goals for this is to have some form of visual like you can find on the Brazil Pixel youtube channel.

example video

BuyMyMojo avatar Jun 12 '25 07:06 BuyMyMojo

Hi,

This can actually be done with a small bit of scripting if you have the imagemagick CLI installed and resdet+spec in your PATH:

#!/usr/bin/env bash

image=$1
output=$2

read full_width full_height < <(identify -ping -format '%w %h' "$image")
read detected_width detected_height < <(resdet -v 1 "$image")

spec "$image" - | magick - -stroke green -draw \
  "line $((full_width-50)),$detected_height $full_width,$detected_height \
   line $detected_width,$((full_height-50)) $detected_width,$full_height" \
  "$output"

Using the example image in the README produces this:

Image

It's possible to add text for the detected_width and height to the magick command. This way you can adjust the brightness of the spectrogram using spec's options also.

0x09 avatar Jun 12 '25 20:06 0x09

@BuyMyMojo I put together a version of this script with a few more options that I think would be good to add to the repo, but let me know if this is the kind of output you had in mind. I do think a script is the best option here for the flexibility and compared to the relative complexity of adding visualization output directly to resdet itself.

0x09 avatar Jun 13 '25 22:06 0x09

Hi there sorry I didn't get a chance to respond to this! this is basically the exact output I had in mind yeah!

BuyMyMojo avatar Jun 14 '25 09:06 BuyMyMojo

Cool then I've added this under src/visualize.sh in https://github.com/0x09/resdet/commit/5210c715e24dc762103b3b90e5f6cb29ba605bb9. The usage is like ./visualize.sh input.png output.png, but there are also some options to set the line length and color and to pass parameters through to resdet and spec. Thanks for the suggestion!

0x09 avatar Jun 14 '25 20:06 0x09

looks great! I'll give it a shot soon!

BuyMyMojo avatar Jun 14 '25 20:06 BuyMyMojo

Finally got a test video up, I think it needs an option for line thickness too.

settings -strokewidth 8 or something should handle this. I'll report back soon!

https://www.youtube.com/watch?v=AGjpCWCs1KE

BuyMyMojo avatar Jun 15 '25 11:06 BuyMyMojo

@BuyMyMojo were there other options that would be useful to add to the script or can this be closed?

0x09 avatar Jul 17 '25 20:07 0x09

Hi I forgot to respond earlier! An option to make the lines thicker if possible would help with visibility when scaled down

BuyMyMojo avatar Jul 18 '25 10:07 BuyMyMojo

Makes sense, https://github.com/0x09/resdet/commit/e05cf97961f9e87e5338a91ad125340d93b120ff adds a new option -t <thickness> which sets the stroke width in the ImageMagick command.

0x09 avatar Jul 18 '25 19:07 0x09